Storing multiple data values different Tables as a single value in parent table - DB relationships
up vote
-1
down vote
favorite
I'm having a issue with with my database organisation, i'm a bit messed up with. Probably something easy who knows. Question is what is better:
- having all data values seperated in the parent tables or
- can I join the 3 values as one single value in parent tables?
My case is:
Table Countries:
Country ID - Name
Table Regions:
Region ID - Name
Table Cities:
City iD - Name
Table Companies:
Company ID - Name - City - Region - Country - etc
OR can I :
Table Countries:
Country ID - Name
Table Regions:
Region ID - Name
Table Cities:
City ID Region Country
and then table cities as a single value in
Table companies:
Company ID - Name - City(city-region-country) - etc
Thanks for your help!
Greets,
Jonathan
mysql foreign-keys relational-database
add a comment |
up vote
-1
down vote
favorite
I'm having a issue with with my database organisation, i'm a bit messed up with. Probably something easy who knows. Question is what is better:
- having all data values seperated in the parent tables or
- can I join the 3 values as one single value in parent tables?
My case is:
Table Countries:
Country ID - Name
Table Regions:
Region ID - Name
Table Cities:
City iD - Name
Table Companies:
Company ID - Name - City - Region - Country - etc
OR can I :
Table Countries:
Country ID - Name
Table Regions:
Region ID - Name
Table Cities:
City ID Region Country
and then table cities as a single value in
Table companies:
Company ID - Name - City(city-region-country) - etc
Thanks for your help!
Greets,
Jonathan
mysql foreign-keys relational-database
Hi. Time to read a textbook on information modeling, the relational model & database design. (Nb--A manual for a design tool, api or language to record designs is not a manual/tutorial on design.) PS This is a faq. Please always google many clear, concise & specific versions/phrasings of your question/problem/goal with & without your particular strings/names & read many answers. If you don't find an answer then post, using 1 variant search as title & keywords for tags. See the downvote arrow mouseover text. When you do have a non-duplicate code question to post please read & act on Minimal, Complete, and Verifiable example.
– philipxy
Nov 11 at 19:19
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm having a issue with with my database organisation, i'm a bit messed up with. Probably something easy who knows. Question is what is better:
- having all data values seperated in the parent tables or
- can I join the 3 values as one single value in parent tables?
My case is:
Table Countries:
Country ID - Name
Table Regions:
Region ID - Name
Table Cities:
City iD - Name
Table Companies:
Company ID - Name - City - Region - Country - etc
OR can I :
Table Countries:
Country ID - Name
Table Regions:
Region ID - Name
Table Cities:
City ID Region Country
and then table cities as a single value in
Table companies:
Company ID - Name - City(city-region-country) - etc
Thanks for your help!
Greets,
Jonathan
mysql foreign-keys relational-database
I'm having a issue with with my database organisation, i'm a bit messed up with. Probably something easy who knows. Question is what is better:
- having all data values seperated in the parent tables or
- can I join the 3 values as one single value in parent tables?
My case is:
Table Countries:
Country ID - Name
Table Regions:
Region ID - Name
Table Cities:
City iD - Name
Table Companies:
Company ID - Name - City - Region - Country - etc
OR can I :
Table Countries:
Country ID - Name
Table Regions:
Region ID - Name
Table Cities:
City ID Region Country
and then table cities as a single value in
Table companies:
Company ID - Name - City(city-region-country) - etc
Thanks for your help!
Greets,
Jonathan
mysql foreign-keys relational-database
mysql foreign-keys relational-database
edited Nov 12 at 2:34
Isaac Bennetch
7,67621629
7,67621629
asked Nov 11 at 17:04
Jon
11
11
Hi. Time to read a textbook on information modeling, the relational model & database design. (Nb--A manual for a design tool, api or language to record designs is not a manual/tutorial on design.) PS This is a faq. Please always google many clear, concise & specific versions/phrasings of your question/problem/goal with & without your particular strings/names & read many answers. If you don't find an answer then post, using 1 variant search as title & keywords for tags. See the downvote arrow mouseover text. When you do have a non-duplicate code question to post please read & act on Minimal, Complete, and Verifiable example.
– philipxy
Nov 11 at 19:19
add a comment |
Hi. Time to read a textbook on information modeling, the relational model & database design. (Nb--A manual for a design tool, api or language to record designs is not a manual/tutorial on design.) PS This is a faq. Please always google many clear, concise & specific versions/phrasings of your question/problem/goal with & without your particular strings/names & read many answers. If you don't find an answer then post, using 1 variant search as title & keywords for tags. See the downvote arrow mouseover text. When you do have a non-duplicate code question to post please read & act on Minimal, Complete, and Verifiable example.
– philipxy
Nov 11 at 19:19
Hi. Time to read a textbook on information modeling, the relational model & database design. (Nb--A manual for a design tool, api or language to record designs is not a manual/tutorial on design.) PS This is a faq. Please always google many clear, concise & specific versions/phrasings of your question/problem/goal with & without your particular strings/names & read many answers. If you don't find an answer then post, using 1 variant search as title & keywords for tags. See the downvote arrow mouseover text. When you do have a non-duplicate code question to post please read & act on Minimal, Complete, and Verifiable example.
– philipxy
Nov 11 at 19:19
Hi. Time to read a textbook on information modeling, the relational model & database design. (Nb--A manual for a design tool, api or language to record designs is not a manual/tutorial on design.) PS This is a faq. Please always google many clear, concise & specific versions/phrasings of your question/problem/goal with & without your particular strings/names & read many answers. If you don't find an answer then post, using 1 variant search as title & keywords for tags. See the downvote arrow mouseover text. When you do have a non-duplicate code question to post please read & act on Minimal, Complete, and Verifiable example.
– philipxy
Nov 11 at 19:19
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
I think the second approach is better because there is a big chance of making your data inconsistent with the first one. Also if you wanna change for example the RegionID of NYC, you will have to make it in one place.
Hint - I think the name of a table should not be in plural form, because of many reasons. If you want I can describe them.
So i think you should have the following tables: Country, Region, City and Company and all your FK's should end with ID. For example City should have RegionID and CityID.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I think the second approach is better because there is a big chance of making your data inconsistent with the first one. Also if you wanna change for example the RegionID of NYC, you will have to make it in one place.
Hint - I think the name of a table should not be in plural form, because of many reasons. If you want I can describe them.
So i think you should have the following tables: Country, Region, City and Company and all your FK's should end with ID. For example City should have RegionID and CityID.
add a comment |
up vote
0
down vote
I think the second approach is better because there is a big chance of making your data inconsistent with the first one. Also if you wanna change for example the RegionID of NYC, you will have to make it in one place.
Hint - I think the name of a table should not be in plural form, because of many reasons. If you want I can describe them.
So i think you should have the following tables: Country, Region, City and Company and all your FK's should end with ID. For example City should have RegionID and CityID.
add a comment |
up vote
0
down vote
up vote
0
down vote
I think the second approach is better because there is a big chance of making your data inconsistent with the first one. Also if you wanna change for example the RegionID of NYC, you will have to make it in one place.
Hint - I think the name of a table should not be in plural form, because of many reasons. If you want I can describe them.
So i think you should have the following tables: Country, Region, City and Company and all your FK's should end with ID. For example City should have RegionID and CityID.
I think the second approach is better because there is a big chance of making your data inconsistent with the first one. Also if you wanna change for example the RegionID of NYC, you will have to make it in one place.
Hint - I think the name of a table should not be in plural form, because of many reasons. If you want I can describe them.
So i think you should have the following tables: Country, Region, City and Company and all your FK's should end with ID. For example City should have RegionID and CityID.
answered Nov 11 at 17:18
Trifon Dardzhonov
312
312
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fstackoverflow.com%2fquestions%2f53251098%2fstoring-multiple-data-values-different-tables-as-a-single-value-in-parent-table%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
Hi. Time to read a textbook on information modeling, the relational model & database design. (Nb--A manual for a design tool, api or language to record designs is not a manual/tutorial on design.) PS This is a faq. Please always google many clear, concise & specific versions/phrasings of your question/problem/goal with & without your particular strings/names & read many answers. If you don't find an answer then post, using 1 variant search as title & keywords for tags. See the downvote arrow mouseover text. When you do have a non-duplicate code question to post please read & act on Minimal, Complete, and Verifiable example.
– philipxy
Nov 11 at 19:19