Solved

Understanding an Entity Relationship Diagram

Posted on 2014-01-29
2
508 Views
Last Modified: 2014-02-01
I am new to databases and am trying to follow an Entity Relationship Diagram (attached). I cannot see how this could be implemented in real life. If you were querying the 'GPA' of a particular student how would you know whether to search in the 'UNDERGRADUATE' or the 'GRADUATE' table. Grateful for any assistance.ERD
0
Comment
Question by:tigger_ranelagh
2 Comments
 
LVL 41

Accepted Solution

by:
pcelba earned 500 total points
ID: 39819556
This ERD means:
Every student (identified by StudentID) can have zero or more records in two child tables.

It is exactly as in the real life. Every people can attend no one, one, or more schools. Schools are divided into two levels in above ERD (you may add possible missing levels).

The connection line between two tables means what is above written:  Student has ONE record in STUDENT table and zero or more records in each of the two child tables.

If you need to query all GPAs for one student then you have to use UNION query:

SELECT HighSchoolGPA FROM UNDERGRADUATE WHERE StudentID = 5
UNION
SELECT UnderGraduateGPA FROM GRADUATE WHERE StudentID = 5

If you need to distinguish between HighSchoolGPA and UnderGraduateGPA in the result then you have to add one more column on output:

SELECT 'H' as GPAtype, HighSchoolGPA FROM UNDERGRADUATE WHERE StudentID = 5
UNION
SELECT 'U' as GPAtype, UnderGraduateGPA FROM GRADUATE WHERE StudentID = 5

More info about ERD: http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model

More info about SQL language: http://www.w3schools.com/sql/default.asp
0
 

Author Closing Comment

by:tigger_ranelagh
ID: 39826202
Many thanks for a very clear explanation.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Database tuning – How to start and what to tune. This question is frequently asked by many people, both online and offline. There is no hard and fast rule-of-thumb for performance tuning, however, before beginning the tuning process one should a…
This article describes some very basic things about SQL Server filegroups.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now