Lecture 7 (Week 7) - Cardinality & modality.pptx

MuhammadMuneerUmar 403 views 28 slides Jan 09, 2023
Slide 1
Slide 1 of 28
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28

About This Presentation

Database Management Systems. Cardinality and Modality


Slide Content

“Database Management Systems” CS-222 Lecture 33 “Cardinality & modality” Dr. Muhammad Muneer Umar By: Lecturer in Computer Science Institute of Computing KUST, Pakistan

Consider some cases An employee can have many children A student must have exactly one father Many teachers are teaching many subjects Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

Agenda Revision of ERD Cardinality and Modality How to read cardinalities Sample Cases Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

-Semantic Data Model -Graphical representation of the conceptual database design Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality ERD ( Entity Relationship Diagram)

-Semantic Data Model -Graphical representation of the conceptual database design Three major constructs: Entity Attributes Relationships Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality ERD ( Entity Relationship Diagram)

Entity Entity Type Entity Instance Entity Set Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

STUDENT LOCATION Entity-Entity Type Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

STUDENT LOCATION Name … ZIP Ali --- 26000 Ahmed --- 25000 ZIP City Province Country 26000 Kohat KPK Pakistan 25000 Peshawar KPK Pakistan 41000 Islamabad Pakistan Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality Entity-Entity Instance & Set

STUDENT 2. Attributes Name FName Age Skills Skills Session Start End Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

STUDENT LOCATION Name … ZIP Ali --- 26000 Ahmed --- 25000 Khan --- 26000 ZIP City Province Country 26000 Kohat KPK Pakistan 25000 Peshawar KPK Pakistan 54000 Lahore Punjab Pakistan 72206 Tehran Tehran Iran 3. Relationships Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

STUDENT LOCATION Name … ZIP Ali --- 26000 Ahmed --- 25000 Khan --- 26000 ZIP City Province Country 26000 Kohat KPK Pakistan 25000 Peshawar KPK Pakistan 54000 Lahore Punjab Pakistan 72206 Tehran Tehran Iran Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality 3. Relationships

Agenda Revision of ERD Cardinality and Modality How to read cardinalities Sample Cases Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

Cardinality  Maximum possible associations 1 OR many Modality  Minimum possible associations 1 OR Zero Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

STUDENT LOCATION Name … ZIP Ali --- 26000 Ahmed --- 25000 Khan --- 26000 ZIP City Province Country 26000 Kohat KPK Pakistan 25000 Peshawar KPK Pakistan 54000 Lahore Punjab Pakistan 72206 Tehran Tehran Iran Modality Cardinality Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

Cardinality and Modality Cardinality and Modality work together to define the relationship Cardinality indicates the maximum number of times an instance in one entity can be associated with instances in the related entity Modality indicates the minimum number of times an instance in one entity can be associated with an instance in the related entity Cardinality and Modality are both shown on the relationship line by symbols Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

Agenda Revision of ERD Cardinality and Modality How to read cardinalities Sample Cases Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

Reading Modality and Cardinality from Zero to Many from One to Many from One to One i.e., one and only one from Zero to One Modality and cardinality are combined (two at a time) in these ways: Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

Student Seat fills Course Instructor teaches Course Student Registers for Transcript Student has Left to right: a seat is filled by exactly one student Right to left: a student fills exactly one seat Left to right: a student has one or more transcripts Right to left: a transcript has one student Left to right: a student registers for one or more courses Right to left: a course is registered by one or more students Left to right: an instructor teaches zero to many courses Right to left: a course is taught by exactly one instructor Reading Cardinality and Modality Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

Student Seat fills Course Instructor teaches Course Student Registers for Left to right: one to one, 1:1 Right to left: one to one, 1:1 Left to right: one to many, 1:M Right to left: many to one, M:1 Left to right: many to many, M:M Right to left: many to many, M:M Left to right: one to many, 1:M Right to left: many to one, M:1 Reading Cardinality Transcript Student has Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

Cardinalities and Modalities Modalities can also be called as: Mandatory Cardinalities = The entity must participate in another entity. Optional Cardinalities = The entity has the option to participate in another entity. Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

Cardinalities and Modalities Cardinalities and modalities can also be defined as: Maximum Cardinality: One or many Minimum Cardinality: Required or not. Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

Agenda Revision of ERD Cardinality and Modality How to read cardinalities Sample Cases Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

EMPLOYEE VEHICLE Name … VID Ali --- IDE403 Ahmed --- Khan --- EGA911 Akbar CSS900 Burhan ACX907 VID Type Model Maker IDE403 Sedan 2017 Toyota ACX907 Hatchback 2013 Suzuki EGA911 SUV 2009 Toyota CSS900 Sedan 2011 Toyota Is it Correct?? Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

EMPLOYEE VEHICLE Name … VID Ali --- IDE403 Ahmed --- Khan --- EGA911 Akbar CSS900 Burhan ACX907 VID Type Model Maker IDE403 Sedan 2017 Toyota ACX907 Hatchback 2013 Suzuki EGA911 SUV 2009 Toyota CSS900 Sedan 2011 Toyota Now it is Correct  Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

EMPLOYEE CHILDREN Name … CID Ali --- C001 Ali --- C002 Khan --- C003 Akbar Burhan C004 CID NAME --- C00 1 Asad C00 2 Ayesha C00 3 Farooq C004 Khalil ??? Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

EMPLOYEE CHILDREN Name … CID Ali --- C001 Ali --- C002 Khan --- C003 Akbar Burhan C004 CID NAME --- C00 1 Asad C00 2 Ayesha C00 3 Farooq C004 Khalil ??? Course: Database Management Systems (CS222) || Instructor: Dr. Muneer Umar, Lecturer. Institute of Computing, KUST || Email: [email protected] Topic: Cardinality & Modality

SUMMARY REVISION OF ERD Cardinality  Maximum cases (1 or many) Modality  Minimum Cases (0 or 1) Mandatory Cardinality  Modality =1 Optional Cardinality  Modality = 0 Possible Cases  1:1, 1:M, M:M (can be read from both direction)

Thank You You any query post your comment on KCMS.
Tags