Simple Question about One-To-Many Relationship between Student and Country Tables - RDBMS SQL

Posted on 2009-06-29
Last Modified: 2013-12-19
I got Student table and Country table

Student {StudentID, Name, CountryID}
Country {CountryID, CountryName}

1. This means every student can have several countries while every country can not have several students! I do not get it. Does the above structure mean no two students can have same country name?

Student {StudentID, Name}
Country {CountryID, CountryName, StudentID}

Every country name can have several students a student can not have several countries. Can you explain please...

It's funny that it sounds simple but my mind does not seem having the sense of getting it...weird
Question by:F-J-K
  • 2
  • 2
LVL 57

Accepted Solution

Raja Jegan R earned 480 total points
ID: 24735519
In your example 1, A Student / StudentID can be assigned to a single CountryID.
So a single Country / CountryID can have several students.

In your Example 2, A Country / CountryID can have A single studentID alone.
And A student / StudentID can have several Countries.

And I believe Example 1 is the correct scenario wherein Many students can belong to a single Country.
Hope this helps and revert if I need to explain more.

Author Comment

ID: 24735553
Ok i got a good picture of it. I will leave the question open for a while then close it....Thanks! A+
LVL 17

Assisted Solution

pssandhu earned 20 total points
ID: 24735570
I agree:
I think every country could have multiple students but a student cannot be affiliated with more than one country. Now, the only thing that comes to mind are immgirants who hold dual citizenship. In that case still I think it will be county of their current fulltime residentship.
Also, the first structure you posted looks much better with COUNTRYID as foreign key to the Country table. If you go with the second strucure you will have to update your Country table every time a new student is registered. In wihch case you are going to have the same country's entry logged in more than once and I am assuming CountryID is a primary Key so it won't allow duplicates.
Hope this helps.
LVL 57

Expert Comment

by:Raja Jegan R
ID: 24735579
Thanks and glad to have helped.

Author Closing Comment

ID: 31597877

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question