Download Entity-Relationship Data Model: Introduction to Database Design and more Summaries Aquaculture and Aquafarming in PDF only on Docsity!
Chapter 2Entity-RelationshipData Model
Introduction2DB - FIT - HCMUS^
Content ^ Process of database design ^ E/R model ^ E/R model design ^ Exercise
Introduction2DB - FIT - HCMUS^
DBMS-independent^ DBMS-specific^4
Process of database design^ Miniworld^ Requirements analysis^ Data requirements^ Conceptual design^ Conceptual schema^ Logical design^ Logical schema^ Physical designInternal schema
Functional requirements Functional analysisHigh-level function specification Application programdesign^ Application^ Applicationprogramsimplementation
Introduction2DB - FIT - HCMUS^
Content ^ Process of database design ^ E/R model^ -^ Entity^ -^ Attribute^ -^ Relationship^ -^ E/R schema^ -^ Keys in E/R model^ -^ Weak entity ^ E/R model design ^ Example
Introduction2DB - FIT - HCMUS^
Entity sets ^ An entity is an abstract object in the real world^ -^ Physical existence (person, car, house…)^ -^ Conceptual existence (company, job, university course...) ^ A collection of similar entities forms an entity set ^ Note^ -^ Entity^ -^ Object^ -^ Entity set^ -^ Class of objects
Structure of data Operations on data
Introduction2DB - FIT - HCMUS^
Entity sets ^ Example^ “Company” database^ -^ An employee is an entity^ -^ The set of all employees constitutes an entity set^ -^ Projects are entities^ -^ The set of projects is an entity set^ -^ A department is another kind of entity^ -^ The set of departments is an entity set
Introduction2DB - FIT - HCMUS^
Relationships ^ The connections among two or more entity sets ^ Example^ -^ Relationships between entity sets EMPLOYEE andDEPARTMENT^ •^ Each employee works for a department^ •^ Each^ department^ has
an^ employee^ who^ manages
that department
Introduction2DB - FIT - HCMUS^
E/R diagrams ^ A^ graph^ representing
entity^ sets,^ attributes,
and
relationships -^ Nodes^ NAME^ Entity sets^ NAME^ Attributes^ Name^ Relationships -^ Edges connect^ •^ An entity set and its attributes^ •^ A relationship and its entity sets
Introduction2DB - FIT - HCMUS^
Instances of an E/R diagram ^ A^ DB^ described^ by^
an^ E/R^ diagram^ will^ containparticular data, which is called the DB instance - Each entity set, the instance will have a particular finiteset of entities • Entity set EMPLOYEE has entities such as E, E, …, E^12
n
-^ Each of entity has particular values for each attribute^ •^ Ehas FName=^ “ Tung^ ”, BirthDate=^1
“ 08/12/1955^ ”, Sex=^ “ Nam^ ”
-^ Ehas Fname=^ “ Hang^ ”, BirthDate=^2
“ 07/19/1966^ ”, Sex=^ “ Nu^ ”
^ Note^ -^ Do not store E/R data directly in a DB^ •^ Is abstract only^ •^ Help us to think about the design before we convert to relations
Introduction2DB - FIT - HCMUS^
Relationship – Instance ^ DB^ instance^ includes
specific^ choices^ of
the
relationships of the diagram -^ A relationship R connects n entity sets E
, E, …, E 12 n
-^ Instance of R consists of a finite set of lists (e
, e, …, e) 12 n
-^ Each eis chosen from the entities that are in Ei^
i
^ Example^ EMPLOYEE^
Works_forEMPLOYEE DEPARTMENTDEPARTMENT TungNghien cuu(Tung, Nghien cuu)(Hang, Dieu hanh)HangDieu hanh(Vinh, Quan ly)Vinh Quan ly
Introduction2DB - FIT - HCMUS^
Relationship – Multiplicity ^ Many-One from E to F ~ One-Many from F to E^ •^ Each^ member^ of^ E^
can^ be^ connected^ at^ most
one member of F • Each member in F can be connected to many members ofE^ E^
(1, n)(1,1)R F r (^1) e 1 f^1 r (^2) e 2 f^2 r (^3) e^ … 3 r (^4) e 4 … …
Introduction2DB - FIT - HCMUS^
Relationship – Multiplicity ^ One-One from E to F^ -^ A member of either entity set can be connected to atmost one entity of the other set^ E^
(0,1)^ (1,1)RF r^1 e 1 f^1 r^2 e 2 f^2 r^3 e 3 ^ f^3 … e 4 … …
Introduction2DB - FIT - HCMUS^
Relationship – Multiplicity ^ (min,max)^ specifies^
the^ minimum^ or^ maximumnumber that each entity e^ ∈^ E can participate in R (min, max) (min, max)R E F • (0,1) – zero or 1 • (1,1) – at least 1 and at most 1 • (0,n) – zero or many • (1,n) – 1 or many
Introduction2DB - FIT - HCMUS^
Relationship – Multiplicity ^ Example^ -^ A department has many employees^ EMPLOYEE^ -^ An employee works for a department^ -^ An employee can work on many projects or do not workon any projects^ -^ An employee can manage a certain department
(1,n)DEPARTMENTWorks_for (1,1) EMPLOYEE DEPARTMENTWorks_for (0,n) EMPLOYEE PROJECTWorks_on (0,1) EMPLOYEE DEPARTMENTManages