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










share|improve this question























  • 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















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










share|improve this question























  • 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













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










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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













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.






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    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',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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
    );



    );













    draft saved

    draft discarded


















    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

























    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.






    share|improve this answer
























      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.






      share|improve this answer






















        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 11 at 17:18









        Trifon Dardzhonov

        312




        312



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            這個網誌中的熱門文章

            Barbados

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3