database design (data modeling)

24
Database Design (Data Modeling) DCO11310 Database Systems and Design By Rose Chang

Upload: howard-herrera

Post on 30-Dec-2015

39 views

Category:

Documents


0 download

DESCRIPTION

Database Design (Data Modeling). DCO11310 Database Systems and Design By Rose Chang. Analysis. Design. Implement. Testing. Production. System Development Life Cycle. Object-Oriented DBMS. ODL, UML, etc. Ideas. Relational DBMS. Relations. ER. Data Modeling. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Database Design (Data Modeling)

Database Design (Data Modeling)

DCO11310

Database Systems and Design

By Rose Chang

Page 2: Database Design (Data Modeling)

2

System Development Life Cycle

Analysis

Design

Implement

Testing

Production

Page 3: Database Design (Data Modeling)

3

Data Modeling

A particular way of representing data Analysis of what information the database must

hold Relationships among components of that

information

Ideas

ODL, UML, etc.

ER

Object-Oriented DBMS

Relational DBMSRelations

Page 4: Database Design (Data Modeling)

4

Data Models

Model ofsystem

in client’smind

Entity model ofclient’s model

Table modelof entity model

Tables on disk

Oracleserver

Page 5: Database Design (Data Modeling)

5

Why Use Data Modelling ?

Programming relies very much on data model Provides a method to reconcile the very different

end-user views of the nature and role of data Helps us to understand the complexity of a real

world data environment Yields a proper “blueprint” of the database

design

Page 6: Database Design (Data Modeling)

6

Steps in Data Modelling

Entity Relationship Modelling Entity Relationship Modelling

Transformation into Data Structures Transformation into Data Structures

Normalisation of Data Structures Normalisation of Data Structures

Analysis of RequirementsAnalysis of Requirements

Page 7: Database Design (Data Modeling)

7

Requirement Analysis

Must incorporate all necessary information from different major users

Identify data requirements Description of data used or generated Details of how data is to be used and generated

Describe information to be recorded Combine into a single global view Analyse the types of transactions to be performed

Page 8: Database Design (Data Modeling)

8

ER Modelling of Requirements

Construct an ER model to describe the data objects and their interrelationships

Identify key attributes Decide on the functionality of relationships

(mandatory or optional) Construct a schematic ER model which gives a

global view of the entire database

Page 9: Database Design (Data Modeling)

9

Transformation of the ER Model to a Schema

Map the ER model onto a set of data structure, or schema

Schema : the description of the organization of a database seen by the DBA

Page 10: Database Design (Data Modeling)

10

Normalisation of the Schema

Reduce each relation to the highest stage of normalisation

BUT designer may wish to refine the resultant schema in order to improve processing efficiency

Page 11: Database Design (Data Modeling)

11

Logical vs. Physical DB Design (II)

Physical DB

Design

Logical DB Design

ViewsProgram Data Selected and derived tables and columns

Tables and columns

How the data is stored in the computer

Page 12: Database Design (Data Modeling)

12

Components of Database Design

The four representations or abstractions will progressively get more details of the system : Data requirements (Textual Information) Conceptual data model (E-R Model) Logical schema (Normalized Entity) Physical Storage schema (Create Table Statements)

Page 13: Database Design (Data Modeling)

13

Conceptual Data Model (I)

1. Identify entity types2. Identify relationship types3. Identify and associate attributes with entity or

relationship types4. Determine attribute domain5. Determine candidate, primary and alternate ket

attributes

Page 14: Database Design (Data Modeling)

14

Conceptual Data Model (II)

6. Validate conceptual model against user transactions

7. Review conceptual data model with user

Page 15: Database Design (Data Modeling)

15

Entity-attribute-relationship Models (EAR)

Used to produce conceptual data model Consists of :

A formal description of each entity in terms of its attributes

Descriptions of the meanings of relationships Descriptions of any constraints The ER diagram

Page 16: Database Design (Data Modeling)

16

Page 17: Database Design (Data Modeling)

17

Entity Relationship Model

There are many notations for ERD such as UML, Chen, Crow’s feet

Create an entity relationship diagram from business specifications or narratives

A department have many employee

EMPLOYEEEMPLOYEE numbernumber namename job titlejob title

DEPARTMENTDEPARTMENT numbernumber namename locationlocation

have

Child entity Parent entity

Page 18: Database Design (Data Modeling)

18

Page 19: Database Design (Data Modeling)

19

Entities Relationship

Define associations among entities All relationships are bi-directional Degrees of relationships

One-to-one relationship (1:1) One-to-many relationship (1:M) Many-many relationship (M:N)

Page 20: Database Design (Data Modeling)

20

Degrees of Relationships

One-to-many Relationship

One-to-one Relationship

EmailEmailStudentStudentStudent-idStudent-nameCourse-code

Account-idusagepassword

have

StudentStudent ProgramProgramStudent-idStudent-nameProgram-code

Program-codeProgram-namehave

Master EntityDetail Entity

Page 21: Database Design (Data Modeling)

21

Many-to-many Relationship

You should resolve it by adding link entity

StudentStudent CourseCourse

MarkMark

Master Entity Master Entity

Link Entity

Student-idStudent-nameProgram-code

Student-idCourse-codemark

Course-codeCourse-name

StudentStudent CourseCourse

Student-idStudent-nameProgram-codeCourse-code

Course-codeCourse-name

take

have

get

belongto

have

for

Page 22: Database Design (Data Modeling)

22

Optional vs. Mandatory Relationship

“A course must be taught by only one lecturer.”

LecturerLecturer CourseCourseteach

“A lecture may teach one or many courses.”

Page 23: Database Design (Data Modeling)

23

Draw an ERD

Each company operates four departments, and each department belongs to one company. Each department employs one or more employees, and each employee works for one department. Each of the employee may or may not have one or more dependants, and each dependant belongs to one employee. Each employee may or may not have an employment history

Page 24: Database Design (Data Modeling)

24

Q & A