# 1 Copyright © 2004 M. E. Kabay. All rights reserved. Database Design (2) IS 240 – Database Management Lecture #11 – 2004-03-18 Prof. M. E. Kabay, PhD,

## Presentation on theme: "1 Copyright © 2004 M. E. Kabay. All rights reserved. Database Design (2) IS 240 – Database Management Lecture #11 – 2004-03-18 Prof. M. E. Kabay, PhD,"— Presentation transcript:

1 Copyright © 2004 M. E. Kabay. All rights reserved. Database Design (2) IS 240 – Database Management Lecture #11 – 2004-03-18 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu

3 Copyright © 2004 M. E. Kabay. All rights reserved. Recursive Relationships (1) Suppose a plant can originate from a single cutting or can produce a single cutting. Diagram this entity here using the E-R notation:

4 Copyright © 2004 M. E. Kabay. All rights reserved. Recursive Relationships (1*) Suppose a plant can originate from a single cutting or can produce a single cutting. Diagram this entity here using the E-R notation: 1:1 Cutting Plant

5 Copyright © 2004 M. E. Kabay. All rights reserved. Recursive Relationships (2) What if a plant can produce several cuttings? Change the diagram to suit this constraint

6 Copyright © 2004 M. E. Kabay. All rights reserved. Recursive Relationships (2*) What if a plant can produce several cuttings? Change the diagram to suit this constraint 1:N Cutting Plant

7 Copyright © 2004 M. E. Kabay. All rights reserved. Recursive Relationships (3) Suppose several plants can have cuttings combined into grafts to produce several other plants. Draw an E-R diagram to represent this situation

8 Copyright © 2004 M. E. Kabay. All rights reserved. Recursive Relationships (3*) Suppose several plants can have cuttings combined into grafts to produce several other plants. Draw an E-R diagram to represent this situation M:N Cutting Plant

9 Copyright © 2004 M. E. Kabay. All rights reserved. Recursive Relationships (4) Now show relations that will model the ER diagrams you developed for the previous slides starting with: 1:1 recursion – 1 plant, 1 cutting

10 Copyright © 2004 M. E. Kabay. All rights reserved. Recursive Relationships (4*) Now show relations that will model the ER diagrams you developed for the previous slides starting with: 1:1 recursion – 1 plant, 1 cutting Plant #1Plant #11 Plant #2Plant #21 Plant #11Plant #111 Source_plant Cutting_plant

12 Copyright © 2004 M. E. Kabay. All rights reserved. Recursive Relationships (5*) Show the relations to model a 1:N recursion – 1 plant, many cuttings Source_plant Cutting_plant Plant #1Plant #11 Plant #1Plant #12 Plant #2Plant #21 Plant #3Plant #31 Plant #3Plant #32 Plant #31Plant #311

13 Copyright © 2004 M. E. Kabay. All rights reserved. Recursive Relationships (6) Show the relations to model an M:N recursion – many plants can combine to produce many grafts

14 Copyright © 2004 M. E. Kabay. All rights reserved. Recursive Relationships (6*) Show the relations to model an M:N recursion – many plants can combine to produce many grafts Plant 1… Plant 2… Plant 3… Plant_ID Other_info Plant_A Plant_B Date_etc Plant 1Plant 2… Plant 1Plant 3… Plant 1Plant 4… Plant 2Plant 4…

18 Copyright © 2004 M. E. Kabay. All rights reserved. Ternary Relationships (2*) Develop relations to model the entity relationships described on the previous slide: Doctor 1Info… Doctor 2Info… Doctor 3Info… Patient 1Info… Patient 2Info… Patient 3Info… Doc1Pat1DateDrug Doc1Pat2DateDrug Doc1Pat3DateDrug Doc2Pat1DateDrug Doc3Pat2DateDrug Doc4Pat3DateDrug Doc4Pat3DateDrug Doc5Pat3DateDrug …

19 Copyright © 2004 M. E. Kabay. All rights reserved. Ternary Relationships (3) For the doctor / patient / prescription relations, How would you model the prescription- doctor-patient relationship if you added the constraint that some drugs must never be prescribed at the same time? Show the relations on the next page

20 Copyright © 2004 M. E. Kabay. All rights reserved. Ternary Relationships (4) Draw the relations showing constrained combinations of drugs Drug 1Info… Drug 2Info… Drug 3Info… Drug 1Drug 4 Drug 1Drug 6 Drug 2Drug 6 Drug 4Drug 1 Drug 6Drug 1 Drug 6Drug 2 First Second DRUG TABLE FORBIDDEN COMBINATIONS Are the duplications a problem?