You are on page 1of 40

Data World

- Database represents a real world which is changing continuously - Data model is the procedure for representing a real world

3 Data Worlds

object properties values

infornation modeling
entity set attributes values

data modeling
record type field values

real world(reality)

conceptual world(concept) computer world(data)

2-1

2. Data Models for Database Systems

Data World (cont'd)


Database and Real World
information modeling

database design
conceptual world

real world

consistency stored database

data structuring

data modeling

logical data structure

2-2

2. Data Models for Database Systems

Data Model Concepts


Data model - conceptual tools for describing data and data relationship - specify the overall logical structure of database Data models fall into three different group : conceptual data model, logical data model and physical data model. Conceptual data model (High-level) - relationship between entity sets, not considering physical storage device - human oriented data model - facilitate database design - Entity-Relationship (E-R) model - OO data model
2-3

2. Data Models for Database Systems

Data Model Concepts (cont'd)


Logical data model (Representational, Implementation) - describing relationship between data field (record-based) - overall logical structure of a database - high level description of the implementation - hierachical model collection of trees - network model collection of record types and links, i.e., graphs - relational model collection of tables

2-4

2. Data Models for Database Systems

Data Model Concepts (cont'd)


Physical data model (Low-level) - describe how data is stored in the computer - e.g. record format, record orderings, and access paths
data structuring data modeling

consistency

stored database physical, low-level model logical, representational model (logical data structure)

2-5

2. Data Models for Database Systems

E-R Model
- by Peter Chen, 1976 - based on a perception of real world which consists of a set of basic objects called entities and relationships among these objects - E-R diagram is graphical database structure in E-R model which is consist of entity set, relationship, attribute and link

Entity - an object that exists and is distinguishable from other objects - ex) Yoon S. A. with social security number 700123-1684321 - may be abstract, such as a holiday or a concept
2-6

2. Data Models for Database Systems

E-R Model (cont'd)


Entity Set - a set of entites of the same type - ex) customer : set of all persons having an account at a bank account : set of all accounts maintained at a bank - rectangles, which represent entity sets - entity sets need not be disjoint a person entity may be an (bank) employee entity, a customer entity, both, or neither Attribute - entity is represented by a set of attributes - ex) customer entity set's attributes are customer-name, security-number, street, and customer-city
2-7

2. Data Models for Database Systems

E-R Model (cont'd)


Domain - a set of permitted values - ex) domain of customer--name : set of all text strings of a certain length Relationship - an association among several entities - ex) Harris(customer) 401(account) Relationship Set - a set of relationships of the same type E1, e2 E2, ... , en En} - {(e1, e2, ... , en) | e1 - ex) CustAcct denote association between customers and accounts - ternary relationship set CAB : Harris, 401, and Redwood
2-8

2. Data Models for Database Systems

E-R Model (cont'd)


Attribute of Relationship - relationship set can have attributes - ex) CustAcct's (Harris, 401) has property {(date, 20 Sept 1995)}

2-9

2. Data Models for Database Systems

Example

2 - 10

2. Data Models for Database Systems

Constraints on Relationship Set


Cardinality ratio constraint number of entities to which another entity can be associated - one-to-one : for each entity in either set, there is at most one associated member of the other set Emp Manages
e1 e2 e3 e4 . . d1 d2 d3 d4 d5 . .

Dept

. .

2 - 11

2. Data Models for Database Systems

Constarints on Relationship Set (cont'd)


- many-to-one : each entity in E1(Courses) is associated with at most one entity in E2(Teachers), but each entity in E2 can be associated any number of entities in E1
Courses taught-by

Teachers

- many-to-many : no restriction

export
Countries

Products

2 - 12

2. Data Models for Database Systems

Constarints on Relationship Set (cont'd)


Participation constraint the existence of an entity depends on the existence of the relationship to another entity - existency dependency this means that if y is deleted, so is x
dominant entity, strong or regular entity subordinate entity, weak entity

2 - 13

2. Data Models for Database Systems

Constarints on Relationship Set (cont'd)


account# Balance transaction# date amount

Account
dominant, strong 462-21-23 262-45-20 645-44-09 ... 3,000 6,000 5,000

Log

Transaction
subordinate, weak 1 4 7 11 Oct 1996 12 Oct 1996 12 Oct 1996 ... +50 +350 - 150

2 - 14

2. Data Models for Database Systems

Keys
it is important to be able to discriminate how entities and relationships Superkey - a set of one or more attribute wich allow us to identify uniquely an entity in the entity set - may have unnecessary attributes to distinct Candidate Key - minimal superkey Primary Key - a candidate key chosen by the DB designer

2 - 15

2. Data Models for Database Systems

E-R Diagram
graphical database structure in E-R model - rectangle : (strong) entity set - double rectangle : weak entity set - ellipse : attribute - diamond : relationship set - line : (1) link attribute to entity set (2) link entity set to relationship set

see Slide 2-11

2 - 16

2. Data Models for Database Systems

Reducing E-R diagrams to Tables


(1) Representation of strong entity sets D1 X D2 X ..... Dn see Fig. 2-14, Fig. 2-15 Korth Book (2) Representation of weak entity sets {attributes of weak entity set} U {primary key of strong entity set) see Fig. 2-16 (3) Representation of relationship sets {primary key set} U {attribute of relationship set R) see Fig. 2-17, Fig 2-18

2 - 17

2. Data Models for Database Systems

Reducing E-R diagrams to Tables (Ex)


account# Balance date transaction# date amount

Account

Log

Transaction

(1)

(2)

(3)

2 - 18

2. Data Models for Database Systems

Generalization
There are similarities between the checking-account entity set and the saving-account entity set in the sense that they have several attribute in common. This commonality can be expressed by generalization.

- Creation method : create a high-level entity set from two or more lower level entity set's common attributes - Usage : is used to emphasize the similarities among lower level entity type and to hide their differences - Inheritance : lower level entity set (saving-account and checking account) inherit the attributes of higher level entity set (account)

2 - 19

2. Data Models for Database Systems

Generalization (cont'd)
account number account balance

saving-account is an account

ISA account number balance

savingaccount

checkingaccount

account number

interestrete

overdraftamount

balance

2 - 20

2. Data Models for Database Systems

Generalization (cont'd)
Transforming E-R diagram including generalization to

tabular form

(1) Primary key of high-level entity set plus lower level entity sets account + savings-account, checking-account
(2) Only lower level entity sets savings-account, checking-account (including higher-level attributes)

2 - 21

2. Data Models for Database Systems

Aggregation
One limitation of the E-R model is that is not possible to express relationship among relationships - Aggregation is an abstraction through which relationships are treated as high-level entities hospital
1

hospitalization
m

doctor
2 - 22

treatment

patients

2. Data Models for Database Systems

DATA MODEL TYPES

2 - 23

2. Data Models for Database Systems

Hierarchical Data Model


Basic Concepts and Structure - Hierarchical database consists of a collection of records which are connected to one another records through links - record : collection of fields (attributes) link : inary relstionship (parent-child relationship) * restriction : only one-to-many
subject prerequisite subject lecture student Hierarchical Definition Tree (subject database schema)

lecturer

2 - 24

2. Data Models for Database Systems

Hierarchical Data Model (cont'd)


subject

C100 Database 3
prerequisite subject C99

ordered tree one-to-many

lecture (record type)


L1 Tue-Thu 2-204 L2 Mon-Wed 3-403 student

lecturer P94 Kim C. S. Computer

S93002 Lee S. H. 85 S93002 Hur S. 92 S93001 Park E. Y. 90

subject Database Tree (record occurrence)


2 - 25

2. Data Models for Database Systems

Hierarchical Data Model (cont'd)


Characteristics - parent-child relationship is one-to-many relationship - ordered tree (left to right) - n:m relationship can be represented by two 1:n representations Restrictions - all record occurrences except root record, must be connected to parent record * need to connect its parent for record insertion * have to delete all its child record for record deletion - one-to-many relationship : to associate with two its parent, make another tree (m:n => two 1:n relationship)
2 - 26

2. Data Models for Database Systems

Network Data Model


Basic Concepts and Structure - Network database consists of a collection of records which are connected to one another records through links but, Data Structure Diagram (DSD) which represent logical structure of network database, is network form - extension of hierarchical data model - CODASYL(Conference on Data Systems Language) DBTG (Data Base Task Group) proposed the network data model formally many-to many link is not allowed (implementation problem) - Network Database System : IDMS (Computer Associates) TOTAL (Cincom Systems) IDS II (Honeywell Information Systems)
2 - 27

2. Data Models for Database Systems

Network Data Model (cont'd)


Data Structure Diagram (DSD)
customer name street city CustAcct number balance account branch name assets city

BrncAcct

2 - 28

2. Data Models for Database Systems

Network Data Model (cont'd)


Set Occurrence (database value)
305 500 Kim Daesin Pusan 226 336 177 205 Chung Choongmu Seoul Uam 5,000,000 Pusan 1: n relationship graph

155 62
Lee Hanbat Taejon 402 100 408 300 Namsan 2,000,000 Ulsan

2 - 29

2. Data Models for Database Systems

Relational Data Model


Background - Proposed by E. F. Codd (1970, ACM TODS) - Non-procedual database language (easy to use) - Standard database language : SQL * ISO, ANSI, X/Open * SQL, SQL89, SQL2, SQL3, .... - Theoretical background (mathematics-based) - Relational DBMSs : Oracle - 2nd largest S/W maker in the world Informix - UNIX RDBMS special group Sybase - Client/Server DBMS Ingres - ?
2 - 30

2. Data Models for Database Systems

Relational Data Model (cont'd)


Overview Relational model = structure + constraints + operation Structure - Domain : set of atomic values - Relational scheme : set of attribute names - Relation : any subset of the Cartesian product of domains of attributes int relation scheme Set of Tuples
Employee E# Ename City 10 Smith 20 James LA NY Workfor Ename Dname Smith James Physics Mathematics

2 - 31

2. Data Models for Database Systems

Relational Data Model (cont'd)


- Terminologies table : relation row : tuple column : attribute - Arity(degree) number of attribute in the relation - Tuple ordered list of values from domain D1, D2, ... , Dn mapping from attribute names to values in the domains ex) (10, Smith, LA) m(E#) = 10, m(Ename) = Smith, m(City) = LA

2 - 32

2. Data Models for Database Systems

Relational Data Model (cont'd)


Integrity Constraints - Entity integrity constraint no primary key can be null - Referential integrity constraints (foreign key constraints) foreign key : set of attributes which is the primary key of another relation foregin key (ex) Dept = (Dname, Manager, Budget) Employee = (Ename, Bdate, Salary, Dname) Every value of the foreign key must exist in the set of the corresponding primary key values of another relation(Dept)

2 - 33

2. Data Models for Database Systems

Relational Data Model (cont'd)


Operation - Operation to manipulate a relation is needed - There are two types of operation, Relational Algebra and Relational Calculus Relational Algebra (How) query is expressed by applying specialized algebraic operators operators => SQL Relational Calculus (What) query is describes a desired set of tuples by specifying a predicate the tuples must satisfy => QUEL, QBE

2 - 34

2. Data Models for Database Systems

Object-Oriented Data Model


Shortcomings of the Conventional Database Technology - Too simple for modeling complex nested entities - A limited set of atomic data types - No frequently useful semantic concepts - Impedance mismatch between programming language and database language - Inappropriate for long-duration transactions necessary in interactive, cooperative design environments (CAD) - Unacceptable for various types of computer-intensive applications

2 - 35

2. Data Models for Database Systems

Object-Oriented Data Model (cont'd)


Additional Features of the Next-Generation Database Systems - Represent and manipulate complex nested objects - Store and retrieve arbitary long data - Define and manipulate arbitary data types - Represent and manipulate various semantic modeling concepts - Specify rules and extented constraints to support inferencing and constraint management - Manage long-duration cooperative transactions

2 - 36

2. Data Models for Database Systems

Object-Oriented Data Model (cont'd)


Object-Oriented Approach - in Programming language from SIMULA-67 (K. Nygard, Norway) Smalltalk, Eiffel, C++, Java - in Artificial Intelligence from introduction of FRAME KEE, ART - in Database from semantic data model E-R, EE-R, SDM, DAPLEX

2 - 37

2. Data Models for Database Systems

Object-Oriented Data Model (cont'd)


Core Modeling Concepts
Account object deposit - Object and Object Identifier withdraw 5000 object = data + operation 100 - Attribute and Methods attribute : specified property to represent an object method : an operation of an object ( = code) - Encapsulation and Message passing encapsulation : the data of an object can only be accessed via the methods of the objects message : a request to perform an operation

Balance

A#

2 - 38

2. Data Models for Database Systems

Object-Oriented Data Model


- Class class : a template from which objects with the same representation and the same behavior can be created - Class Hierarchy and Inheritance inheritance : a mechanism which allows a new class to be incrementally defined from an existing class
instantiation class object 1 object 2
2 - 39

instantiation

2. Data Models for Database Systems

Object-Oriented Data Model


Object-Oriented Database Concepts
EMP
data part Name Lee Age 25 Salary 500,000 Lee is an EMP object

operation part (hire, change Age, change Salary)

Account object : all 6% : $1000 -> 5% $1000 -> 6% pay-interest Balance 5000 A# 100

2 - 40

2. Data Models for Database Systems

You might also like