Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Model 11 After this lecture, you should be able to:  Use E-R Model effectively to design a database from requirements.  Know to convert from E-R.

Similar presentations


Presentation on theme: "Data Model 11 After this lecture, you should be able to:  Use E-R Model effectively to design a database from requirements.  Know to convert from E-R."— Presentation transcript:

1 Data Model 11 After this lecture, you should be able to:  Use E-R Model effectively to design a database from requirements.  Know to convert from E-R diagram to Relational diagram.  Complete Assignment 2 (Part I) and Quiz 1 (Friday) Introduction to ER modeling and relational databases

2 Data Model 12  Entity-Relationship (E-R) Modeling  Entities and relationships  Instance diagrams and E-R diagrams  Relational Database  Tables, rows, and columns  Conversion from an E-R diagram to relational tables Tables for entities Tables for relationships Outline

3 Data Model 13  Department Information  Department D1 is Marketing with budget $10M.  Department D2 is Development with budget $12M.  Department D3 is Research with budget $5M.  Employee Information  Employee E1 is named Lopez, belongs to D1, and earns $40K.  Employee E2 is named Cheng, belongs to D1, and earns $42K.  Employee E3 is named Finzi, belongs to D2, and earns $30K.  Employee E4 is named Saito, belongs to D2, and earns $35K. Department–Employee Database

4 Data Model 14 Suppliers-Parts Database  Supplier S1 named A is located in San Jose, its total amount of annual sales is $20M.  Supplier S2 named B is located in Austin, its total amount of annual sales is $10M.  Part P1 is a black monitor and weighs 4 Kg.  Part P2 is an ivory-color keyboard and weighs 1 Kg.  Part P3 is a yellow mouse and weighs 0.2 Kg.  S1 supplies P1 for $300 per unit, P2 for $40, and P3 for $10.  S2 supplies P1 for $400 per unit and P2 for $50.

5 Data Model 15 Accident & Insurance Database  Link: Click hereClick here

6 Data Model 16  Department Information  Department D1 is Marketing with budget $10M.  Department D2 is Development with budget $12M.  Department D3 is Research with budget $5M.  Employee Information  Employee E1 is named Lopez, belongs to D1, and earns $40K.  Employee E2 is named Cheng, belongs to D1, and earns $42K.  Employee E3 is named Finzi, belongs to D2, and earns $30K.  Employee E4 is named Saito, belongs to D2, and earns $35K. Department–Employee Database

7 Data Model 17 Department–Employee Database: Instance Diagram D1 Marketing 10M E1 Lopez 40K E2 Cheng 42K E3 Finzi 30K E4 Saito 35K D2 Development 12M D3 Research 5M

8 Data Model 18 Department–Employee Database: E-R Diagram (Schema) Dept has Emp Budget Salary Ename Emp# (key) Dept# (key) DName 1M

9 Data Model 19 Department-Employee Database: Relational Tables Emp#ENameDept#Salary E1LopezD140K E2ChengD142K E3FinziD232K E4SaitoD235K DEPT (Departments) EMP (Employees) Dept#DNameBudget D1Marketing10M D2Development12M D3Research5M

10 Data Model 110 Entities  Entity  ≈ Object, ≈≈Record  Instance of an entity type  Entity Type  Kind of entities  ≈ Object Type (Class), ≈≈ Record Type  Property, ≈Attribute, ≈≈ Field  Drawn as a rectangle

11 Data Model 111 Relationships and Relationship Types  Relationship Instance  Instance of a relationship type  ≈ Link, ≈≈Edge  Relationship Type  Type of Similar Relationships  ≈ Association  Drawn as a diamond.

12 Data Model 112 Suppliers-Parts Database  Supplier S1 named A is located in San Jose, its total amount of annual sales is $20M.  Supplier S2 named B is located in Austin, its total amount of annual sales is $10M.  Part P1 is a black monitor and weighs 4 Kg.  Part P2 is an ivory-color keyboard and weighs 1 Kg.  Part P3 is a yellow mouse and weighs 0.2 Kg.  S1 supplies P1 for $300 per unit, P2 for $40, and P3 for $10.  S2 supplies P1 for $400 per unit and P2 for $50.

13 Data Model 113 Suppliers-Parts Database: Instance Diagram S1 A San Jose $20M S2 B Austin $10M P3 Mouse Yellow 0.2 P2 Keyborad Ivory 1.0 P1 Monitor Black 4.0 $300 $40 $50 $10 $400

14 Data Model 114 Suppliers-Parts Database: E-R Diagram S supply P AddressColor Name P# (key) S# (key) Name WeightSalesPrice M M

15 Data Model 115 Suppliers-Parts Database: Relational Tables S#NameAddressSales S1ASan Jose$20M S2BAustin$10M S (Supplier) P#NameColorWeight P1MonitorBlack4.0 P2KeyboardIvory1.0 P3MouseYellow0.2 P (Part)

16 Data Model 116 Suppliers-Parts Database: Table SP S#P#Price S1P1$300 S1P2$40 S1P3$10 S2P1$400 S2P2$50 Supply (Supplier_Part)

17 Data Model 117 Rules to convert E-R Diagram to Relational Schema  An Entity Type is mapped to a Relation (table): Each attribute of the entity type becomes an attribute of the table.  For each 1:N Relationship Type, put the key of 1-side Table to the N-side Table.  For each 1:1 Relationship Type, put the key of one side Table to the other side Table.  For each N:N Relationship Type, create a new table. Put the keys of two tables to make the key for new table.

18 Data Model 118 Many-to-Many 1-to-1 1-to Many Multiplicities of Relationship Types Person name address Person name address 11 married-to Person name address Account machine name 1* has Person name address School name address ** attended


Download ppt "Data Model 11 After this lecture, you should be able to:  Use E-R Model effectively to design a database from requirements.  Know to convert from E-R."

Similar presentations


Ads by Google