ER Diagram [message #554468] |
Mon, 14 May 2012 13:20 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](http://www.gravatar.com/avatar/68568470b692c197c4d2467477efafb3?s=64&d=mm&r=g) |
GaneshAnanth
Messages: 34 Registered: January 2011 Location: Thanjavur
|
Member |
|
|
Could any of you please explain the HR diagram in the attachment.
I know the key highlighted in blue color are Primary Key.
I do want to understand which one is parent table and which one is the child table.
For example:
1. Region table needs to be created first and region_id needs to be set as primary key.
2 Countries table needs to be created second and region_id as foreign key and country_id as primary key.
Please explain - I need to implement this table to practice
Thanks in advance.
Ganesh
![/forum/fa/10153/0/](/forum/fa/10153/0/)
[mod-edit: jpg attachment inserted into message body by bb]
-
Attachment: HR.JPG
(Size: 37.93KB, Downloaded 13095 times)
[Updated on: Tue, 15 May 2012 17:06] by Moderator Report message to a moderator
|
|
|
Re: ER Diagram [message #554480 is a reply to message #554468] |
Mon, 14 May 2012 14:21 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13923 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Region is parent to country.
A line between tables that splits into three indicates a one to many relationship. The three being the many obviously.
In a one to many relationship the one is always the parent.
|
|
|
Re: ER Diagram [message #554527 is a reply to message #554480] |
Tue, 15 May 2012 03:32 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](http://www.gravatar.com/avatar/68568470b692c197c4d2467477efafb3?s=64&d=mm&r=g) |
GaneshAnanth
Messages: 34 Registered: January 2011 Location: Thanjavur
|
Member |
|
|
Hi Cookiemonster,
I know Region is parent and country in child.
There are Tables like Region, Country, Lacation, Departments, Employees, Jobs and Job History.
I am explaining here. Please correct me if I am wrong
Order in which Table and constraints to be created
1. Region Table, region_id - primary key
2. Country Table, country_id - primary key & region_id - foreign key references region_id in Region Table
3.Lacations Tbale, location_id - primary key & country_id - foreign key references country_id in Countries Table.
4. Department Table, department_id - Primary key & location_id - foreign key references location_id in Locations Table.
Confirm these are correct and explain for other tables Employees, Jobs and Job History.
Thanks,
Ganesh
|
|
|
|
|
|
Re: ER Diagram [message #554669 is a reply to message #554574] |
Wed, 16 May 2012 06:25 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
cookiemonster
Messages: 13923 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
1) departments.manager_id references employees.employee_id. Employees.department_id references departments.department_id. You'll need to create the fks after both tables have been created.
3) job_history isn't parent to anything. So it's pk shouldn't be referenced by anything.
|
|
|