ENTITY RELATIONSHIP MODEL Popular high level conceptual data

  • Slides: 52
Download presentation

ENTITY RELATIONSHIP MODEL ﻧﻤﻮﺫﺝ ﺍﻟﻜﺎﺋﻨﺎﺕ ﺍﻟﻤﺮﺗﺒﻄﺔ Popular high_ level conceptual data Model , developed

ENTITY RELATIONSHIP MODEL ﻧﻤﻮﺫﺝ ﺍﻟﻜﺎﺋﻨﺎﺕ ﺍﻟﻤﺮﺗﺒﻄﺔ Popular high_ level conceptual data Model , developed • by Peter Chen (1976). -: • ﺍﻟﻤﻔﺎﻫﻴﻢ ﺍﻷﺴﺎﺳﻴﺔ ﻟﻠﻨﻤﻮﺫﺝ Entities ﺍﻟﻜﺎﺋﻨﺎﺕ. 1 Attributes ﺍﻟﺼﻔﺎﺕ. 2 Relationships ﺍﻟﻌﻼﻗﺎﺕ. 3

Entity Type name : - Attributes: - employee Name, age , salary E 1

Entity Type name : - Attributes: - employee Name, age , salary E 1 company Name, No, president C 1 Ali , 30000 Entity sets (extension) Sisco, ab 60, omer E 2 C 2 Ahmed, 40, 50000 ……. ……… Nilegroup, ac 360, ali ……. . . The collection of all entities of a particular entity type in the database at any point in time is called an entity set. Entity type & entity set have the same name.

 ﺃﺸﻜﺎﻝ ﺍﻧﻮﺍﻉ ﺍﻟﺼﻔﺎﺕ • Multivalued attribute: - • Composite attribute : Sub parts

ﺃﺸﻜﺎﻝ ﺍﻧﻮﺍﻉ ﺍﻟﺼﻔﺎﺕ • Multivalued attribute: - • Composite attribute : Sub parts attribute Composite attribute name

 • Derived Attribute : -

• Derived Attribute : -

An Example Database Application • Company DB requirements: • The company has several departments.

An Example Database Application • Company DB requirements: • The company has several departments. Each department has a unique name, a unique number, and a particular employee who manages the department. we keep track of the start date when the employee began managing the department. A department may have several locations. • A department controls a number of projects, each of which has a unique name, a unique number, and a single location.

Cont. • We store each employee's name, social security number, address, salary, sex, and

Cont. • We store each employee's name, social security number, address, salary, sex, and birth date. An employee is assigned to one department but may work on several projects. We keep track of the number of hours per week that an employee works on each project. • We want to keep track of the dependents of each employee for insurance purposes. We keep each dependent ‘s first name , sex, birth date, and relationship to the employee.

 ﺍﻟﺘﺤﺪﻳﺪ ﺍﻹﺑﺘﺪﺍﺋﻰ ﻟﻞ E. Ts ﻭﺍﻟﺼﻔﺎﺕ ﻟﻘﺎﻋﺪﺓ ﺍﻟﺒﻴﺎﻧﺎﺕ Company • Four Entity types

ﺍﻟﺘﺤﺪﻳﺪ ﺍﻹﺑﺘﺪﺍﺋﻰ ﻟﻞ E. Ts ﻭﺍﻟﺼﻔﺎﺕ ﻟﻘﺎﻋﺪﺓ ﺍﻟﺒﻴﺎﻧﺎﺕ Company • Four Entity types : 1. Department Attributes: Name , Number, Location , Manager start date. • Location : - Multivalued attribute. • Name, Number: - Separate Key Attribute ( )ﺃﻲ ﺻﻔﺔ ﻣﻨﻬﻢ ﻳﻤﻜﻦ ﺍﻥ ﺗﻤﺜﻞ ﺍﻟﻤﻔﺘﺎﺡ 2. Project: Attributes: - Name, Number, Location, Controlling Departments. Name or Number ( )ﺃﻲ ﺻﻔﺔ ﻣﻨﻬﻢ ﻳﻤﻜﻦ ﺍﻥ ﺗﻤﺜﻞ ﺻﻔﺔ ﺍﻟﻤﻔﺘﺎﺡ

Cont. 3. Employee : • Attributes: - Name, SSN, Sex, Address, Salary, Birth date,

Cont. 3. Employee : • Attributes: - Name, SSN, Sex, Address, Salary, Birth date, Department, Supervisor. • Name and Address: - composite Attributes. 4. Dependant • Attributes: Employee, Dependant Name, Sex, Birth date, Relation (Employee).

Relationships (ﺍﻧﻮﺍﻉ ﺍﻟﻌﻼﻗﺎﺕ Relationship types) -: ● Relationship type R among n entity types

Relationships (ﺍﻧﻮﺍﻉ ﺍﻟﻌﻼﻗﺎﺕ Relationship types) -: ● Relationship type R among n entity types E 1, . …. , En defined as a set of associations (or relationship set) among entities from these types. Relationship: types: R. Ts) (Remark : - ( ●

 • R: Relationship type (or relationship set ) • E 1 , E

• R: Relationship type (or relationship set ) • E 1 , E 2 : Entity types , Each of one is said to participate in relationship type R • r 1 , r 2 , r 3, …, r 7 : relationship instances (or set ). • (individual entities) (e 1, e 2, e 3, …, e 7) and (e'1, e'2, e'3) are said to participate into relationship instances. ﻣﻦ ﻣﺠﻤﻮﻋﺔ ﺍﻧﻬﺎ ﻋﻠﻲ relationship type ﺍﻟـ ﺗﻌﺮﻳﻒ ﻳﻤﻜﻦ • ﻭﻟﺬﺍ (e 1, …. en) individual entities ﺍﻝ ﺑﻴﻦ ﺗﺮﺑﻂ ﻭﺍﻟﺘﻲ (ri) instances ( participant entity types) ﻟـ ﻛﺎﺋﻨﺎﺕ ﻫﻲ (e 1, …. en) ﺣﻴﺚ

: ﻣﺜﺎﻝ ● ● ● Works- for : Relationship type Participant entity types: Employee

: ﻣﺜﺎﻝ ● ● ● Works- for : Relationship type Participant entity types: Employee and Department ﺑﻴﻦ ﺍﻟﻌﻼﻗﺔ ﺃﻦ ﺃﻲ Department , Employee) ﺍﻟﺬﻱ ﻭﺍﻟﻘﺴﻢ )ﺍﻟﻤﻮﻇﻒ ( ( ﺑﻪ

R. T in E-R diagram Std no Student std name Teach-on University name University

R. T in E-R diagram Std no Student std name Teach-on University name University

 • • • e 1 supervisor of e 2 supervised by e 1

• • • e 1 supervisor of e 2 supervised by e 1 (all participating entity In R. T belong to only one E. T) e 1 r 2 e 3

 ﻣﺜﺎﻝ father f 1 mother m 1 parent r 1 child c 1

ﻣﺜﺎﻝ father f 1 mother m 1 parent r 1 child c 1

Cont. 1 -cardinality ratio constraints: ﺍﻟﺜﻨﺎﺋﻴﺔ ﻟﻠﻌﻼﻗﺔ Cardinality ratio ﺍﻝ ﺗﺤﺪﻳﺪ • ﻭﻳﺘﻢ ﻭﺍﻟﺘﻲ

Cont. 1 -cardinality ratio constraints: ﺍﻟﺜﻨﺎﺋﻴﺔ ﻟﻠﻌﻼﻗﺔ Cardinality ratio ﺍﻝ ﺗﺤﺪﻳﺪ • ﻭﻳﺘﻢ ﻭﺍﻟﺘﻲ (relationship Instances) ﺍﻝ ﻋﺪﺩ ﺑﺘﺤﺪﻳﺪ . (participant entity ) ﻓﻴﻬﺎ ﻳﺸﺎﺭﻙ • (Specifies the relationship type instances that an entity can participate in)

Department : Employee ﺑﻴﻦ works – for ﺍﻟﻌﻼﻗﺔ : • ﻣﺜﺎﻝ • Cardinality ratio

Department : Employee ﺑﻴﻦ works – for ﺍﻟﻌﻼﻗﺔ : • ﻣﺜﺎﻝ • Cardinality ratio = 1: N (N zero or more) One: Many : ﻛﺎﻻﺗﻲ E. R diagram ﻓﻲ ﺫﻟﻚ ﻭﻳﻮﺿﺢ Department 1 Works-for N Employee

Cont. • Possible cardinality ratio for binary R. T s: • 1: N, N:

Cont. • Possible cardinality ratio for binary R. T s: • 1: N, N: 1, 1: 1, M: N • One : Many , Many : One , One : One, Many : Many : N: 1 • ﻣﺜﺎﻝ ﻝ Student N Teach-on 1 University

Cont. one : one ﺍﻟﻌﻼﻗﺔ ﻧﻮﻉ : ﻣﺜﺎﻝ Employee 1 Manages 1 Department •

Cont. one : one ﺍﻟﻌﻼﻗﺔ ﻧﻮﻉ : ﻣﺜﺎﻝ Employee 1 Manages 1 Department •

Cont. Many : Many ﻋﻼﻗﺔ ﻟﻨﻮﻉ : • ﻣﺜﺎﻟﺐ Employee M Works-for N Project

Cont. Many : Many ﻋﻼﻗﺔ ﻟﻨﻮﻉ : • ﻣﺜﺎﻟﺐ Employee M Works-for N Project

 (Weak entity types ﺍﻧﻮﺍﻉ ﺍﻟﻜﺎﺋﻨﺎﺕ ﺍﻟﻀﻌﻴﻔﺔ . ﺍﻟﻤﻔﺘﺎﺡ ﺻﻔﺔ ﺛﻤﺜﻞ ﺻﻔﺎﺕ ﺍﻭ ﺻﻔﺔ

(Weak entity types ﺍﻧﻮﺍﻉ ﺍﻟﻜﺎﺋﻨﺎﺕ ﺍﻟﻀﻌﻴﻔﺔ . ﺍﻟﻤﻔﺘﺎﺡ ﺻﻔﺔ ﺛﻤﺜﻞ ﺻﻔﺎﺕ ﺍﻭ ﺻﻔﺔ ﻟﻬﺎ ﻟﻴﺴﺖ entity types • ﻫﻲ ﻛﺎﺋﻨﺎﺕ ﻣﻊ ﺑﻌﻼﻗﺘﻬﺎ ﺍﻻ ﺗﻤﻴﺰ ﻻ weak entity type ﻟﻞ ﺗﻨﺘﻤﻰ ﺍﻟﺘﻲ • ﺍﻟﻜﺎﺋﻨﺎﺕ weak E. Ts ﻭﺍﻝ (owner or parent) ﺍﺧﺮ entity type ﻝ ﺗﻨﺘﻤﻲ ﺍﺧﺮﻯ . (child E. Ts) ﻋﻠﻴﻬﺎ ﻳﻄﻠﻖ • Child entity types participation is total participation in the relation – type between( child) weak entity type and parent entity type. R. T is called (Identifying R. T)

 • In E-R digram: Identifying relationship type Weak entity type

• In E-R digram: Identifying relationship type Weak entity type