48
1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah | [email protected] | http://www.sitinur151.wordpress.com | | A2-3039 | ext:2561 | 012-7760562 | CHAPTER 2 Data Models

1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

  • View
    231

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

1

ITS232Introduction To Database Management Systems

Siti Nurbaya IsmailFaculty of Computer Science & Mathematics,

Universiti Teknologi MARA (UiTM), Kedah| [email protected] | http://www.sitinur151.wordpress.com |

| A2-3039 | ext:2561 | 012-7760562 |

CHAPTER 2Data Models

Page 2: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2

Chapter 2: Data Models

2.0 DATA MODELS 2.1 The Importance of Data Models 2.2 Data Model Basic Building Blocks 2.3 Business Rules 2.4 The Evolution of Data Models 2.5 Degrees of Data Abstraction

Page 3: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models2.1 The Importance of Data Models

3

Data models Relatively simple representations, usually graphical of complex real-world

data structures Facilitate interaction among the designer, the applications programmer, and

the end user End-users have different views and needs for data Data model organizes data for various users

Page 4: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models2.2 Data Model Basic Building Blocks

4

Entity

anything about which data are to be collected and stored

Attribute

a characteristic of an entity

Relationship

describes an association among entities

Constraint

a restriction placed on the data

Page 5: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.2 Data Model Basic Building Blocks

5

Entity Attribute Relationship Constraint

Page 6: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.3 Business Rules

6

Brief, precise, and unambiguous descriptions of policies, procedures, or principles within a specific organization

Apply to any organization that stores and uses data to generate information

Description of operations that help to create and enforce actions within that organization’s environment

Page 7: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.3 Business Rules

7

Must be rendered in writing Must be kept up to date Sometimes are external to the organization Must be easy to understand and widely disseminated Describe characteristics of the data as viewed by the company:

•corresponds to a table (ERD)

Entities

•associations between entities

Relationships

•characteristics of entities

Attributes

•describe the relationship classification

Connectivity

•limitations on the type of data accepted

Constraints

Page 8: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.3 Business Rules: Discovering Business Rules

8

Sources of Business Rules– Company managers– Policy makers– Department managers– Written documentation

• Procedures• Standards• Operations manuals

– Direct interviews with end users

Page 9: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.3 Business Rules: Business Rules Example

9

One student can register many subjects

A painter can paint many paintings; each paining is painted by one painter. A gallery can have many paintings. A painting can be exhibited by a gallery.

Page 10: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.3 Business Rules:

10

Translating Business Rules into Data Model Components

Standardize company’s view of data Constitute a communications tool between users and designers Allow designer to understand the nature, role, and scope of data Allow designer to understand business processes Allow designer to develop appropriate relationship participation rules and

constraints Promote creation of an accurate data model

Page 11: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.3 Business Rules: Discovering Business Rules

11

Generally, nouns translate into entities Verbs translate into relationships among entities Relationships are bi-directional Fact finding techniques:

– The formal process of using techniques such as interview and questionnaire to collect facts about system, requirements and preferences.

– To captures the essential facts necessary to build the required database• What facts are collected?

– Captured facts about the current and/or future system

Page 12: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.3 Business Rules: Fact Finding Techniques

12

Examining documents

Interviewing

Observation the organization in

operationsResearch

Questionnaire 5 commonly used fact finding

techniques

Page 13: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

13

Hierarchical Database Model• Represented by a group of records that relates to each others by a

pointer

Network Database Model• Based on set theory, a set consists a collection of records

Relational Database Model• Based on the mathematical concept of relational

Object-Oriented Model• Based on object oriented concepts

Hierarchical Database Model• Represented by a group of records that relates to each

others by a pointer Root & Child

Network Database Model• Based on set theory, a set consists a collection of

records Owner & Member

Relational Database Model• Based on the mathematical concept of relational

Object-Oriented Model• Based on object oriented concepts

Page 14: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

14

Developed in the 1960s to manage large amounts of data for complex manufacturing projects

Basic logical structure is represented by an upside-down “tree” or by a group of records that relates to each others by a pointer– The uppermost record is a Root/Parent– The lower record in a hierarchy is a Child

Depicts a set of one-to-many (1:M) relationships between a parent and its children segments – Each parent can have many children– each child has only one parent

Can only support 1:1 and 1:M relationships where a child can only have one parent

Hierachical Database Model

Page 15: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

15

Hierachical Database Model

Page 16: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

Advantages of Hierachical Database Model Many of the hierarchical data

model’s features formed the foundation for current data models

Its database application advantages are replicated, albeit in a different form, in current database environments

Generated a large installed (mainframe) base, created a pool of programmers who developed numerous tried-and-true business applications

Disadvantages of Hierachical Database Model Complex to implement Difficult to manage Lacks structural independence Implementation limitations Lack of standards

16

2.0 Data Models 2.4 The Evolution of Data Models

Page 17: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

17

Develop in 1970 in Conference on Data Systems Languages (CODASYL), by Database Task Group (DBTG)

Created to:– Represent complex data relationships more effectively – Improve database performance– Impose a database standard

Based on set theory, where a set consists of a collection of records

Network Database Model

Page 18: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

18

Resembles hierarchical model Collection of records in 1:M relationships Composed of at least two record types

Owner – Equivalent to the hierarchical model’s parent

Member– Equivalent to the hierarchical model’s child

Can support 1:1, 1:M and M:N relationships where a child can have more than one parent.

Network Database Model

Page 19: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

19

Network Database Model

Page 20: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

20

Disadvantages– Too cumbersome– The lack of ad hoc query capability put heavy pressure on programmers– Any structural change in the database could produce havoc in all

application programs that drew data from the database– Many database old-timers can recall the interminable information

delays

Network Database Model

Page 21: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

21

Developed by Codd (IBM) in 1970, considered ingenious but impractical in 1970

Conceptually simple, based on mathematical concept of relational Backwards, computers lacked power to implement the relational model Today, microcomputers can run sophisticated relational database software Relational Database Management System (RDBMS) Performs same basic functions provided by hierarchical and network DBMS

systems, in addition to a host of other functions Most important advantage of the RDBMS is its ability to hide the

complexities of the relational model from the user

Relational Model

Page 22: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

22

Relational Model

•Matrix consisting of a series of row/column intersections

•Related to each other through sharing a common entity characteristic

Table (relations)

•Representation of relational database’s entities, attributes within those entities, and relationships between those entities

Relational diagram

•Stores a collection of related entities

•Resembles a file

Relational Table

•How data are physically stored in the database is of no concern to the user or the designer

•This property became the source of a real database revolution

Relational table is purely logical structure

Page 23: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

23

Example of table structure/relational table

Relational Model

Page 24: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

24

Example of table with data/relational table

Relational Model

Page 25: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

25

Example of table relationship/relational diagram

Relational Model

Relationship: An employee has one department. One department has many employee.

EMPLOYEE DEPARTMENThasM 1

Page 26: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

26

Rise to dominance due in part to its powerful and flexible query language Structured Query Language (SQL) allows the user to specify what must be

done without specifying how it must be done SQL-based relational database application involves:

– User interface– A set of tables stored in the database– SQL engine

Relational Model

Page 27: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

27

Entity Relationship (E-R) Model– Introduced by Chen in 1976– Widely accepted and adapted graphical tool for data modeling– Graphical representation of entities and their relationships in dB

structure– Entity Relationship Diagram (ERD)

• Uses graphic representations to model database components• Entity is mapped to a relational table

Relational Model

Page 28: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

28

Example of ERD

Relational Model

Page 29: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

29

Modeled both data and their relationships in a single structure known as an object

OO data model (OODM) is the basis for the OO database management system (OODBMS)

Object Oriented Model

Page 30: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

30

Object described by its factual content – Like relational model’s entity

Includes information about relationships between facts within object, and relationships with other objects– Unlike relational model’s entity

Subsequent OODM development allowed an object to also contain all operations

Object becomes basic building block for autonomous structures

Object Oriented Model

Page 31: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

31

Object is an abstraction of a real-world entity Attributes describe the properties of an object Objects that share similar characteristics are grouped in classes Classes are organized in a class hierarchy Inheritance is the ability of an object within the class hierarchy to inherit

the attributes and methods of classes above it

Object Oriented Model

Page 32: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models 2.4 The Evolution of Data Models

32

A comparison of the OO model and the ER model

Object Oriented Model

Page 33: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data ModelsA Summary

33

Each new data model capitalized on the shortcomings of previous models

Common characteristics: – Conceptual simplicity without compromising the semantic

completeness of the database– Represent the real world as closely as possible– Representation of real-world transformations (behavior) must comply

with consistency and integrity characteristics of any data model

Page 34: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data ModelsA Summary

34

Page 35: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models2.5 Degrees of Data Abstraction

35

Way of classifying data models– Data abstraction:

• hides extraneous information regarding data storage away from database user

Many processes begin at high level of abstraction and proceed to an ever-increasing level of detail

Page 36: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models2.5 Degrees of Data Abstraction

36

American National Standards Institute (ANSI) Standards Planning and Requirements Committee (SPARC)

Three Level ANSI-SPARC Architecture– Defined a framework for data modeling based on degrees of data

abstraction(1970s):

External

Conceptual

Internal

Page 37: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models2.5 Degrees of Data Abstraction: Data Abstraction Levels

37

Page 38: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models2.5 Degrees of Data Abstraction

38

2. Conceptual level

3. Internal level

Physical data organization

1. External level View 1 View 2 View n

Conceptual Schema

Internal Schema

Database

User nUser 2User 1

Conceptual Model

External Model

Internal Model

Physical Model

-designer’s view-h/w independent-s/w independent

-DBMS’s view-h/w independent-s/w dependent

-h/w dependent-s/w dependent

-user’s view

ERD

Three Level ANSI-SPARC Architecture

Page 39: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models2.5 Degrees of Data Abstraction: External Model

39

End users’ view of the data environment Requires that the modeler subdivide set of requirements and constraints

into functional modules that can be examined within the framework of their external models

Advantages:– Easy to identify specific data required to support each business unit’s

operations– Facilitates designer’s job by providing feedback about the model’s

adequacy– Creation of external models helps to ensure security constraints in the

database design– Simplifies application program development

Conceptual Model

External Model

Internal Model

Physical Model

Page 40: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models2.5 Degrees of Data Abstraction: Conceptual Model

40

Global view of the entire database concept of the dB– Describe what data is stored in the dB and relations among the data

Data as viewed by the entire organization logical structure communication tool between users and designer

Basis for identification and high-level description of main data objects, avoiding details use as basic database bluprint

Most widely used conceptual model is the entity relationship (ER) model Provides a relatively easily understood macro level view of data

environment

Software and Hardware Independent– Does not depend on the DBMS software used to implement the model – Does not depend on the hardware used in the implementation of the

model– Changes in either hardware or DBMS software have no effect on the

database design at the conceptual level

Conceptual Model

External Model

Internal Model

Physical Model

Page 41: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models2.5 Degrees of Data Abstraction: Internal Model

41

Representation of the database as “seen” by the DBMS– Describes how the data is stored in the dB

Maps the conceptual model to the DBMS Internal schema depicts a specific representation of an internal model Physical representation of the dB on the computer

Software Dependent and Hardware Independent– Depend on the DBMS software used to implement the model – Does not depend on the hardware used in the implementation of the

model

Conceptual Model

External Model

Internal Model

Physical Model

Page 42: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models2.5 Degrees of Data Abstraction: Internal Model

42

The Physical Model

Operates at lowest level of abstraction, describing the way data are saved on storage media such as disks or tapes – how the data is stored in the database

Software and Hardware Dependent– Requires that database designers have a detailed knowledge of the

hardware and software used to implement database design

Conceptual Model

External Model

Internal Model

Physical Model

Page 43: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data ModelsSummary

43

A data model is a (relatively) simple abstraction of a complex real-world data environment

Basic data modeling components are:– Entities– Attributes– Relationships– Constraints

Data modeling requirements are a function of different data views (global vs. local) and level of data abstraction

Page 44: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

2.0 Data Models Summary

44

Hierarchical Database Model• Represented by a group of records that relates to each others by a

pointer

Network Database Model• Based on set theory, a set consists a collection of records

Relational Database Model• Based on the mathematical concept of relational

Object-Oriented Model• Based on object oriented concepts

Hierarchical Database Model• Represented by a group of records that relates to each

others by a pointer Parent & Child 1:1 & 1:M

Network Database Model• Based on set theory, a set consists a collection of

records Owner & Member 1:1& 1:M & M:N

Relational Database Model• Based on the mathematical concept of relational

Object-Oriented Model• Based on object oriented concepts

Page 45: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

45

Exercise 1

It is important to understand business rules when designing a database. Define business rules.

(1 mark) State TWO (2) reasons the importance of business rules in database

design. (2 marks)

Give ONE (1) example of business rules. (1 mark)

Page 46: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

46

Exercise 2

Briefly explain the hierarchical and network database model, and what is the difference between those two database models?

(6 marks)

Page 47: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

47

Exercise 3

What is the different between external, conceptual and internal model?(7 marks)

Page 48: 1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah

48

Exercise 4

What is a conceptual model and why it is important in database design?(4 marks)