1. Trang chủ
  2. » Công Nghệ Thông Tin

Lecture Database management systems Chapter 2 Entity relationship model

34 229 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 34
Dung lượng 904,2 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Lecture Database management systems Chapter 2 Entity relationship model. This chapter includes contents Introduction, overview of database design, ER model basics, symbols used in ER diagram, attribute classification, ER diagram, relationship degree, relationship classification,...

Trang 1

Chapter 2

Entity Relationship Model

Trang 2

Introduction

 Modeling databases using a graphical

technique is proposed so that humans can relate to easily

 ER Model is based on a perception of a real world that consists of collection of basic objects called entities and

relationships among these objects

Trang 3

Overview of Database Design

 Conceptual design: ( ER Model is used at this stage )

 A database “schema” in the ER Model can be represented pictorially (ER diagrams)

 The next step in DB design is the actual implementation of the database, using a commercial DBMS

 By using the DBMS, conceptual design from high-level data model will be transformed into the implementation data model

Trang 4

COMPANY example

 The COMPANY database keeps track of company’s employee, departments, and

projects

 Suppose that after the requirement

collection and analysis phase, the database designers provide the following

description:

Trang 6

COMPANY example

 We store each EMPLOYEE’s name social security number, address, salary, sex, and birthdate

 Each employee works for one department but may

work on several projects

 We keep track of the number of hours per week that an employee currently works on each project We also

keep track of the direct supervisor of each employee

 Each employee may have a number of

DEPENDENTs

 For each dependent, we keep track of their name, sex, birthdate, and relationship to the employee

Trang 7

◦ Ex:

 A particular person, for example Dr Alain is an entity

 A particular department, for example CSE faculty

 A particular place, for example HCM city can be an entity

Trang 8

ER Model Basics

 Entity type or entity set: collection of similar entities

◦ Ex:

 All students in CSE, say STUDENT

 All courses in CSE, say COURSE

 An entity may belong to more than one entity type

◦ Ex: The same person is a LECTURER at one instance and STUDENT at another instance

Trang 9

ER Model Basics

 Relationship: associations among two or more entities

 Ex:

◦ An Dang works in Pharmacy department

◦ Teaches is the relationship type between LECTURER and STUDENT

Trang 10

Symbols Used in ER Diagram

Entity sets

AttributesRelationships

Trang 11

ER Model Basics

 Attributes: properties of entity

 Ex: Roll number, name, and grade are the attributes of STUDENT

Trang 12

Attribute classification

1

Trang 16

Attribute classification

 Composite Attribute

Trang 17

ER Diagram

Trang 18

Key attribute

 An important constrain on the entities of

an entity type is the KEY on attributes

 An attribute of an entity type for which

each entity must have a unique value is called a key attribute of the entity type

 For example, SSN of EMPLOYEE

 Each key is underlined

Trang 19

Relationship degree

 Unary Relationship (recursive

relationship):

◦ In the unary relationship the number of

associated entity is one An entity related to itself is known as recursive relationship

Trang 23

Relationship Classification

 One-to-Many Relationship Type:

The relationship that associates one entity to more than one entity is called one-to-many

Trang 24

Relationship Classification

 One-to-One Relationship Type:

◦ a special case of one-to-many relationship

◦ True one-to-one relationship is rare

◦ Symbol:

◦ Ex: The relationship between the President and the country is an example of one-to-one relationship

PRESIDENT COUNTRY

Trang 25

Relationship Classification

 Many-to-Many Relationship Type

◦ Ex: The relationship between students and courses

◦ Symbol:

Trang 26

Relationship Classification

 Many-to-One Relationship Type

◦ Ex: The relationship between EMPLOYEE and DEPARTMENT is an example of many- to-one relationship There may be many

EMPLOYEES working in one

DEPARTMENT

Trang 27

Relationship Classification

Trang 28

Reducing ER Diagram to Tables

 Mapping Entities:

◦ Regular entities

 Entity name = Name of the relation or table

 Attributes of ER diagram=Column name of the

table

Trang 29

Reducing ER Diagram to Tables

 Mapping Composite Attribute:

CUSTOMER (Customer-ID, Customer name,

Street, City, State, Zip)

Trang 30

Reducing ER Diagram to Tables

 Mapping Multivalued Attribute:

 EMPLOYEE (Employee-ID, Name, Address)

 EMPLOYEE-SKILL (Employee-ID, Skill)

Trang 31

Reducing ER Diagram to Tables

 Mapping one-to-Many Relationship:

 EMPLOYEE (Customer-ID, Name, Address)

 ORDER (Order-ID, Order-Date, Customer-ID)

Trang 32

Reducing ER Diagram to Tables

 Mapping one-to-Many Relationship:

 EMPLOYEE (Customer-ID, Name, Address)

 ORDER (Order-ID, Order-Date, Customer-ID)

Trang 33

Reducing ER Diagram to Tables

 Mapping Many-to-Many Relationship:

 EMPLOYEE(Customer-ID, Name, Other attributes)

 SHIPMENT(Shipment-No, Customer-ID, Vendor-ID, Date Amount)

 ORDER (Vendor-ID, Address, Other Attributes)

Ngày đăng: 15/05/2017, 11:13

TỪ KHÓA LIÊN QUAN