Download presentation
Presentation is loading. Please wait.
1
Entity-Relationship Model
2
Entity/Relationship Modelling
Example In a University database we might have entities for Students, Modules and Lecturers. Students might have attributes such as their ID, Name, and Course, and could have relationships with Modules (enrolment) and Lecturers (tutor/tutee) Entities - Real-world object distinguishable from other objects Attributes - properties of an entity Relationships - links between entities Entity Relationship Modelling
3
Entity/Relationship Diagrams
Conceptual design Build a model independent of the choice of DBMS E/R Models are often represented as E/R diagrams that Give a conceptual view of the database Are independent of the choice of DBMS Faculty ID Name Course Teaches Student Studies Module Entity Relationship Modelling
4
E-R Diagrams Rectangles represent entity sets.
Diamonds represent relationship sets. Lines link attributes to entity sets and entity sets to relationship sets. Ellipses represent attributes Double ellipses represent multivalued attributes. Dashed ellipses denote derived attributes. Underline indicates primary key attributes
5
Other way of representation
Entity Relationship Modelling
6
Entity Relationship Modelling
An entity is represented by a set of attributes, that is descriptive properties possessed by all members of an entity set. Example: customer = (customer-id, customer-name, customer-street, customer-city) loan = (loan-number, amount) Entity Relationship Modelling
7
Entity Relationship Modelling
Entity Set: A collection of similar entities. E.g., all employees. Each entity set has a key. Each attribute has a domain. Domain – the set of permitted values for each attribute Eg: the names given for the attribute column ‘name’. Entity Relationship Modelling
8
Entity Relationship Modelling
Simple attribute – An attribute with single value, cannot be sub divided. Composite attribute – An attribute which can be sub divided. Null attribute – When an entity does not have a value for an attribute null value is used. Eg: An employee has no dependent, then dependent_name column will be null (value unknown) Entity Relationship Modelling
10
Entity Relationship Modelling
11
E-R Diagram With Composite, Multivalued, and Derived Attributes
12
Roles Entity sets of a relationship need not be distinct
The labels “manager” and “worker” are called roles; they specify how employee entities interact via the works-for relationship set. Roles are indicated in E-R diagrams by labeling the lines that connect diamonds to rectangles. Role labels are optional, and are used to clarify semantics of the relationship
13
Entity Relationship Modelling
Relationships Relationships are an association between two or more entities Each Student takes several Modules Each Module is taught by a Lecturer Each Employee works for a single Department Relationships have A name A set of entities that participate in them A degree - the number of entities that participate (most have degree 2) A cardinality ratio Entity Relationship Modelling
14
Cardinality Constraints
15
One-To-Many Relationship
16
Many-To-One Relationships
In a many-to-one relationship a loan is associated with several (including 0) customers via borrower, a customer is associated with at most one loan via borrower
17
Many-To-Many Relationship
18
Entity Relationship Modelling
Consider Works_In: An employee can work in many departments; a dept can have many employees. Entity Relationship Modelling
19
Entity Relationship Modelling
Making E/R Models To make an E/R model you need to identify Enitities Attributes Relationships Cardinality ratios General guidelines Since entities are things or objects they are often nouns in the description Attributes are facts or properties, and so are often nouns also Verbs often describe relationships between entities Entity Relationship Modelling
20
Entity Relationship Modelling
Example A university consists of a number of departments. Each department offers several courses. A number of modules make up each course. Students enrol in a particular course and take modules towards the completion of that course. Each module is taught by a lecturer from the appropriate department, and each lecturer tutors a group of students Entity Relationship Modelling
21
Entity Relationship Modelling
Example - Entities A university consists of a number of departments. Each department offers several courses. A number of modules make up each course. Students enrol in a particular course and take modules towards the completion of that course. Each module is taught by a lecturer from the appropriate department, and each lecturer tutors a group of students Entity Relationship Modelling
22
Example - Relationships
A university consists of a number of departments. Each department offers several courses. A number of modules make up each course. Students enrol in a particular course and take modules towards the completion of that course. Each module is taught by a lecturer from the appropriate department, and each lecturer tutors a group of students Entity Relationship Modelling
23
Entity Relationship Modelling
Example - E/R Diagram Entities: Department, Course, Module, Lecturer, Student Department Course Module Lecturer Student Entity Relationship Modelling
24
Entity Relationship Modelling
Example - E/R Diagram Each department offers several courses Offers Department Course Module Lecturer Student Entity Relationship Modelling
25
Entity Relationship Modelling
Example - E/R Diagram A number of modules make up each courses Offers Department Includes Course Module Lecturer Student Entity Relationship Modelling
26
Entity Relationship Modelling
Example - E/R Diagram Students enrol in a particular course Offers Department Includes Course Module Lecturer Enrols In Student Entity Relationship Modelling
27
Entity Relationship Modelling
Example - E/R Diagram Students … take modules Offers Department Includes Course Module Lecturer Takes Enrols In Student Entity Relationship Modelling
28
Entity Relationship Modelling
Example - E/R Diagram Each module is taught by a lecturer Offers Department Includes Teaches Course Module Lecturer Takes Enrols In Student Entity Relationship Modelling
29
Entity Relationship Modelling
Example - E/R Diagram a lecturer from the appropriate department Offers Employs Department Includes Teaches Course Module Lecturer Takes Enrols In Student Entity Relationship Modelling
30
Entity Relationship Modelling
Example - E/R Diagram each lecturer tutors a group of students Offers Employs Department Includes Teaches Course Module Lecturer Takes Enrols In Tutors Student Student Entity Relationship Modelling
31
Entity Relationship Modelling
Example - E/R Diagram Offers Employs Department Includes Teaches Course Module Lecturer Takes Enrols In Tutors Student Entity Relationship Modelling
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.