Updating inverse side bidirectional association
I understand (more or less) the concept of unidirectional
and bidirectional
association in a relationship, but I don't see the correct practical application of it.
For example, I want an contact
table which contains a FK for the country
, so I don't have to store the countries every time I create an address but just keep a reference to an already existing country.
As far as I understand, this should be a ManyToOne
relationship contact(M) --> country(1)
as one contact
can only have one country
but one country can be used by many contacts. This makes contacts the ONWING
side of the relationship and country the INVERSE
side as contact will hold the FK.
In the Doctrine documentation I read that it will only look after changes in the owning side. Does this mean that the table contact won't be updated if a country ID changes, which is exactly what I want it to do?
Also, what I would need is to get the country name to join it in the contact entry and not in reverse. This is the purpose of the bidirectional association, right?
Hope not be messing things up (too much)
mysql relational-theory orm
bumped to the homepage by Community♦ 8 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I understand (more or less) the concept of unidirectional
and bidirectional
association in a relationship, but I don't see the correct practical application of it.
For example, I want an contact
table which contains a FK for the country
, so I don't have to store the countries every time I create an address but just keep a reference to an already existing country.
As far as I understand, this should be a ManyToOne
relationship contact(M) --> country(1)
as one contact
can only have one country
but one country can be used by many contacts. This makes contacts the ONWING
side of the relationship and country the INVERSE
side as contact will hold the FK.
In the Doctrine documentation I read that it will only look after changes in the owning side. Does this mean that the table contact won't be updated if a country ID changes, which is exactly what I want it to do?
Also, what I would need is to get the country name to join it in the contact entry and not in reverse. This is the purpose of the bidirectional association, right?
Hope not be messing things up (too much)
mysql relational-theory orm
bumped to the homepage by Community♦ 8 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I understand (more or less) the concept of unidirectional
and bidirectional
association in a relationship, but I don't see the correct practical application of it.
For example, I want an contact
table which contains a FK for the country
, so I don't have to store the countries every time I create an address but just keep a reference to an already existing country.
As far as I understand, this should be a ManyToOne
relationship contact(M) --> country(1)
as one contact
can only have one country
but one country can be used by many contacts. This makes contacts the ONWING
side of the relationship and country the INVERSE
side as contact will hold the FK.
In the Doctrine documentation I read that it will only look after changes in the owning side. Does this mean that the table contact won't be updated if a country ID changes, which is exactly what I want it to do?
Also, what I would need is to get the country name to join it in the contact entry and not in reverse. This is the purpose of the bidirectional association, right?
Hope not be messing things up (too much)
mysql relational-theory orm
I understand (more or less) the concept of unidirectional
and bidirectional
association in a relationship, but I don't see the correct practical application of it.
For example, I want an contact
table which contains a FK for the country
, so I don't have to store the countries every time I create an address but just keep a reference to an already existing country.
As far as I understand, this should be a ManyToOne
relationship contact(M) --> country(1)
as one contact
can only have one country
but one country can be used by many contacts. This makes contacts the ONWING
side of the relationship and country the INVERSE
side as contact will hold the FK.
In the Doctrine documentation I read that it will only look after changes in the owning side. Does this mean that the table contact won't be updated if a country ID changes, which is exactly what I want it to do?
Also, what I would need is to get the country name to join it in the contact entry and not in reverse. This is the purpose of the bidirectional association, right?
Hope not be messing things up (too much)
mysql relational-theory orm
mysql relational-theory orm
asked Aug 6 '15 at 18:40
lusoluso
1085
1085
bumped to the homepage by Community♦ 8 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 8 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Huh? Sounds like the textbooks are making things too complicated, with too much terminology.
Yes, "country" involves a many:1 relationship. Yes there are 2 tables. Yes, country_id
is in both tables. OK, you could have a FK relationship. Or you could simply make sure you insert into Countries
whenever you come across a new country
.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f109270%2fupdating-inverse-side-bidirectional-association%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Huh? Sounds like the textbooks are making things too complicated, with too much terminology.
Yes, "country" involves a many:1 relationship. Yes there are 2 tables. Yes, country_id
is in both tables. OK, you could have a FK relationship. Or you could simply make sure you insert into Countries
whenever you come across a new country
.
add a comment |
Huh? Sounds like the textbooks are making things too complicated, with too much terminology.
Yes, "country" involves a many:1 relationship. Yes there are 2 tables. Yes, country_id
is in both tables. OK, you could have a FK relationship. Or you could simply make sure you insert into Countries
whenever you come across a new country
.
add a comment |
Huh? Sounds like the textbooks are making things too complicated, with too much terminology.
Yes, "country" involves a many:1 relationship. Yes there are 2 tables. Yes, country_id
is in both tables. OK, you could have a FK relationship. Or you could simply make sure you insert into Countries
whenever you come across a new country
.
Huh? Sounds like the textbooks are making things too complicated, with too much terminology.
Yes, "country" involves a many:1 relationship. Yes there are 2 tables. Yes, country_id
is in both tables. OK, you could have a FK relationship. Or you could simply make sure you insert into Countries
whenever you come across a new country
.
answered Aug 7 '15 at 4:25
Rick JamesRick James
43.7k22259
43.7k22259
add a comment |
add a comment |
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f109270%2fupdating-inverse-side-bidirectional-association%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown