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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

Question has a verified solution.

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

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…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

688 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