Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

18
SE-381 Software Engineering BEIT-V Lecture # 19 (Entity Relationship and Attribute Analysis & Data Modelling)

description

Software Engineering, Lectures

Transcript of Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Page 1: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

SE-381Software Engineering

BEIT-VLecture # 19

(Entity Relationship and Attribute Analysis & Data Modelling)

Page 2: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Data Modeling– Data Modeling, Semantic Modeling, Entity Relationship

Diagrams, Entity Relationship Attribute Modeling, Object Data Classes etc are various names for the same technique, commonly known as Data Modeling.

– Different authors have used slightly different notations to represent Entities, Relationships and Object Data Classes

– Notations used by Chen 1976 (the founder of the technique) and Baynon-Davies 1989 are followed. Some unlearning and re-learning may be required to those who have already learnt and used it in their Data Bases course

– Data Modeling supplements the Process Modeling technique and helps in identifying the data structures on which the system is to be built

Page 3: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Entity Relationship Modelling• One of the Oldest techniques used in Database

and Information Systems Design, proposed by Chen 1976

• Representation of ‘Real World’ in terms of Entities, Attributes and Relationships between the Entities

An Entity is a thing which the enterprise recognizes as being capable of an independent existence and which can be uniquely identified (Howe, 1983)

An Entity may be an Object, concept or an event having characteristics of independent existence and unique identification, and should have data items or attributes associated with it.

An Entity together with its attributes define an Entity Type of which there may be many instances. Similarly, a Relationship Type may have many instances, where occurrences of allied Entities are participating

Page 4: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Relationship

A Relationship isan association between two or more entities. (Howe, 1983)

The common attribute in two Entities, indicates they have some relationship.

For N entities, there could be N(N-1)/2 possible relations, as every Entity being part of the systems will be related to every other entity so only direct relationships between the Entities are considered

Parent Child SchoolGoesSponsors

Parent and Child and Child and School have direct relationships, but the relationship between Parent and School is indirect or derived relationship which should not be considered

Page 5: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Cardinality or Degree of the Relationship

• It is number of instances of the respective entity type participating in the relationship.

• It can be one-to-one (1:1), one-to-many (1:M) or many-to-many (M:N)

• Crow-Foot notation used to represent cardinality

Class Student

CourseStudent

Cheque PaymentBrings

Consists_of

Read

Page 6: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Membership Class or Optionality

• Membership is Mandatory if every occurrence of the entity participates in the relationship

• Membership is Optional if some of the instances of respective entity do exist but don’t participate in the relationship, or some occurrences of the entity can exist independently– Every Employee must be employed within a Department– A Department may exist without any (full-time) Employee

• For Mandatory Entity we put in ‘a filled dot’ within the Entity, and for Optional Entity it is put outside on the Relationship

Cheque PaymentBrings

Employee DeprttWorks

Cheque PaymentBrings

Page 7: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Assignment Rules

1:1 Relationship– Membership Mandatory on Both Entity Types

– Membership Mandatory for only one Entity Type

Cheque PaymentBrings

Single table is needed

Cheque (Cheque_no, date, sign, amount, … , Payment_Id, …)

Employee CarUses

Two tables needed, post the identifier of Optional into Mandatory

Employee (Employee_no, Name, Designation, …)

Car (Reg_no, Model, Capacity, …., Employee_no )

Page 8: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Assignment Rules– Membership Optional for both Entity Types

Employee CarUses

Three tables needed, one for each Entity and one for Relationship

Employee (Employee_no, Name, Designation, …)

Car (Reg_No, Model, Capacity, …. )

Uses ( Employee_no, Reg_no, …., Mileage_used_by)

Page 9: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Assignment Rules

1:M Relationship– Membership of many ‘Entity’ is Mandatory,

Ward PatientContains

Two tables needed

Ward (Ward_no, Location, type, …)

Patient ( Patient_Id,, Name, date_of_Admiss, …, Ward_no)

– Membership of many ‘Entity’ is also Optional

Ward PatientContains

Three tables neededWard (Ward_no, Location, type, …)Patient ( Patient_Id,, Name, date_of_Admiss, …)Contains (Patient_no, Ward_no)

Page 10: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Assignment Rules

M:N Relationship– Will need Three Tables irrespective of membership class

Teacher StudentTutors

Three tables neededTeacher (Teacher_name, Subject, Qualification …)Student ( Reg_no,, Name, date_of_Admiss, Semester …)Tutors (Teacher_name, Reg_no)

Page 11: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Drawing of E-R Diagrams

Following steps be followed to draw E-R Diagrams

1. Identify Entities from the problem definition2. Investigate and record their inter-relationships3. Draw E-R diagram showing Entities and Relationships4. Indicate Degree and Membership Class of each Relationship5. Validate the ERD against the System Requirements6. Rationalize 7. Revalidate8. Using Assignment Rules, convert the diagram into set of fully

normalized tables

Page 12: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

ERD - A Case StudyDesign an appropriate information system for the patients’ appointments and operations activities of a large general hospital. Initial analysis provide the following brief description of the existing manual system:

• Patients are dealt with by an appointment system• Patients must make an appointment for a clinic session held at

one of the hospital’s clinics• Doctors are allocated one or more appointments within a clinic

session, but only one doctor will be present at each appointment

• Operations are scheduled and allocated to one of a number of theatre sessions held in the hospital’s operating theatres, each doctor may perform a number of given operations on patients

1. First identify the set of Entities from the above description

Page 13: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Entities of the System

HOSPITALCLINICCLINIC-SESSIONAPPOINTMENTPATIENTDOCTOROPERATIONOPERATING-THEATRETHEATRE-SESSION

2. Investigate and record Inter-relationshipsHow many total relations are possible, Identify the direct Relations

3. Draw E-R diagram showing Entities and Relationships

Page 14: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

First-Pass ERD

Page 15: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Eliminate the Indirect Relationships

4. Indicate and draw the Optionality of the relationships

Page 16: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Second-Pass ERD

Page 17: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

Set of Tables Generated

Page 18: Beit 381 se lec 19 - 18 - 12 apr24 - eraa and data modeling

References

1. NIIT (2005); System Analysis and Design for Software Engineers; Printice-Hall of India, New Delhi

2. Paul Beynon-Davies (1989); Information Systems Development, Macmillan, London, UK; Ch-5 Entity – Relationship Diagrams pp:38-54

3. P. P-S Chen (1976); the Entity-Relationship Model – Toward a Unified View of Data; ACM Transactions on Database Systems 1, pp:9-36

4. Any book on Data Bases or Data Modeling