Solved

Understanding an Entity Relationship Diagram

Posted on 2014-01-29
2
515 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
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…

777 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