Вы находитесь на странице: 1из 12

Outline

Database

CSC3064
Database Engineering

Types of database
Database Schema
Database models

Lecture 1
Muthu
muthma@sunway.edu.my

Data

Meta data
Metadata describes how and when and by whom a
particular set of data was collected, and how the data
is formatted.

Data can be classified as raw facts or the building


block of information.

These are usually unprocessed information.


Data can exists in a variety of forms such as numbers
or text on pieces of paper and bytes stored in
electronic memory, or as facts stored in a persons
mind.

Information

Data management

Information can be classified as processed data.

Data Management is a discipline that focuses on


the proper generation, storage and retrieval of data

Information should be meaningful, relevant,


accurate and timely.
These are essential ingredients to good decisionmaking, which is the key to organizational success.

What is a database?

Database organization

A collection of information organized in such a way


that a computer program can quickly select desired
pieces of data.

A field is a single piece of information that has a


specific meaning and is used to define and store data.
A record is one complete set of fields describing a
person, place or thing.

Databases are organized as fields, records, and


files.

A file is a collection of related records.

Database management system

Advantages of DBMS

To access information from a database, you need a


database management system

The end-users has better access to more and bettermanaged data.

A DBMS is a collection of programs that enables you


to store, modify, and extract information from a
database.

Allows integrated view of organizations data


leading.
The ability to produce quick responses to ad hoc

DBMSs makes data management more effective

queries.

10

Types of Databases

DBMS Facilities
Data Manipulation Language
has a central repository for all data and data descriptions
provides inquiry facilities to this data called a query
language.
Data Definition Language
allows users to specify the data-type and structures, and
the constraints on that data to be stored in the database

Single-user database
Desktop database
Multi-user database
Workgroup database
Enterprise database

11

12

Database Design

Other classifications of Databases


A centralized database is one that supports data located

Database design refers to the design of the database

at a single site.

structure that will be used to store and manage data.

A distributed database is a single logical database that is

spread physically across computers in multiple locations

It does NOT refer to the designing the DBMS software.

The transactional database is used to process

A well- designed database will minimize the problem of

transactions

data-redundancy.

A data-warehouse database focuses on storage of data

that will be used for information generation for the


purpose of decision-making.

A poorly designed database tends to generate errors

13

Schema

14

Database Schema vs. Database State

Database Schema:
The description of a database.
Includes descriptions of the database structure,
data types, and the constraints on the database.

Distinction
The database schema changes very infrequently.
The database state changes every time the database is
updated.

15

16

Example of a database state

Example of a Database Schema

17

Three-Schema Architecture

18

Three-Schema Architecture
Defines DBMS schemas at three levels:
Internal schema at the internal level to describe physical
storage structures and access paths (e.g. indexes).

Proposed to support DBMS characteristics of:


Program-data independence.
Support of multiple views of the data.
Not explicitly used in commercial DBMS products,
but has been useful in explaining database system
organization

Typically uses a physical data model.

Conceptual schema at the conceptual level to describe the

structure and constraints for the whole database for a


community of users.

Uses a conceptual or an implementation data model.

External schemas at the external level to describe the

various user views.

19

Usually uses the same data model as the conceptual schema.

20

The three-schema architecture

Data Independence
Logical Data Independence:
The capacity to change the conceptual schema
without having to change the external schemas and
their associated application programs.
Physical Data Independence:
The capacity to change the internal schema without
having to change the conceptual schema.
For example, the internal schema may be changed
when certain file structures are reorganized or new
indexes are created to improve database performance

21

Business rules

22

Business rules
Examples
A customer may generate many invoices.

A clear description of a policy, procedure, or principle

within an organizations environment.

Properly written business rules are used to define entities,

attributes relationships and constraints.

Only one customer generates each invoice.

To be effective, a business rule must be easy to

A minimum of 15 participants is needed for the

understand and widely disseminated to ensure that every


person in the organization shares a common
interpretation.

training to be scheduled

23

24

Business rules Why?

Hierarchical Model

They help standardize the companys view of data.


They constitute a communications tool between users
and designers.
They allow the designer to understand the nature,
role and scope of all data.
They allow the designer to understand business
processes.
They allow the designer to develop appropriate
relationship participation rules and constraints. .

Records are arranged in a top-down structure


The parent and child are often used in describing
hierarchical model
a child is related to only one parent

25

26

Network Data Model

Hierarchical Model

no distinction between parent and child record

types

DEPARTMENT
DEPTNO DNAME LOCATION

Any record type may be associated with any number of


EQUIPMENT
IDENT COST NUMBER

different record types

EMPLOYEE
EMPNO ENAME YEARS

network schema - the conceptual organization of the

entire database as viewed by the database administrator.

DEPENDENT
DNAME AGE

SKILL
CODE SNAME NOYEARS

The subschema, which defines the portion of the

database seen by the application programs that


actually produce the desired information from the
data contained in the database.

27

28

Relational Model

Network Data Model

Based on the mathematical concept of a relation, represented as a

table.
DEPARTMENT

A table stores a collection of related entities.

DEPTNO DNAME LOCATION

DEPT-EMP

The database resembles a file but a unlike a file a table yields

DEPT-PROJ
PROJECT

EMPLOYEE
EMPNO ENAME YEARS

complete data and structural independence because it is purely


logical.

PROJNO DESCRIPTION

How the data is stored in the database is of no consequence to the

PROJ-EMP

user or designer.
A table is a matrix made up a series of row and columns.

29

30

Advantages of the Relational model

Relational Model

Structural Independence

Bno.

Street

location

PostCode

TelNo.

B1

22, Oxley Rd

Central

589652

67894561

Improved conceptual simplicity

B2

44, Shenton Way

South

548796

67896325

Easier design, implementation and management

B3

11, Chai Chee Rd

East

585698

67665892

Ad hoc query capability

B4

4, Jurong West Drive

West

526478

68875425

Powerful DBMS

Fname

Lname

Position

Salar
y

Sex

Bno

S11

John

Doe

Manager

5000

B1

S12

Stella

Chan

Clerk

1800

B3

S14

Muthu

Ramasam
y

Senior Exec

3200

B3

Sno.

31

32

Object-oriented Model

Disadvantages of the Relational model

Objects are abstraction of the real world entities that


exhibit states and behaviors

Substantial overhead
Can facilitate poor design and implementation

state of objects is expressed as values of the attributes


of the object

Promote islands of information problem

behavior of an object is expressed by a set of methods


that operate on its attributes.

33

34

Advantages of the OO model


Features of OO data model
An object is an abstraction of real-world entity. It represents a single

Add semantic content

Attributes describe the properties of an object. Objects that share

Visual presentation includes semantic content.

A class is a collection of similar objects with shared structure.

Database integrity

occurrence of an entity.

similar characteristics are grouped in classes.

A method represents a real-world action such as display; to print out

Both structural and data independence

the details of the Student. Methods define the behavior of an object.

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(parent).

35

36

Disadvantages of the OO model


Slow pace of OODM standards and development
Complex navigational data access
Steep learning curve
High systems overhead slows transactions .

37

Tables

Relational Database Model

Logical view of the relational database is facilitated


by the creation of relationships based on a logical
construct known as a table or a relation.

View of data is logical rather than physical.


DBMS in between the application and database
allows the designer to focus on the logical
representation of the data and their relationships.

39

40

Table characteristics

Table - example

A table is composed of rows and columns.


Each row (tuple) represents a single occurrence.
Each column represents an attribute and is uniquely
named.
Each row/column intersection represents a single piece
of data.
All values in a single column must be of the same data
format.
The range of possible values of a column is known as
the attribute domain.
Each table must have an attribute or combination of
attributes that uniquely identifies each row.

Bno.

Street

location

PostCode

Tel No.

B1

22, Oxley Rd

Central

589652

67894561

B2

44, Shenton Way

South

548796

67896325

B3

11, Chai Chee Rd

East

585698

67665892

B4

4, Jurong West Drive

West

526478

68875425

42

41

Relational Keys

Relational Keys

Candidate Key It is an attribute or combination of attributes

that enables each row to be uniquely identified.

Primary key It is an attribute or a set of attributes that uniquely

identify a specific instance of an entity.

Composite Key It is a primary key that made up of more than

one attribute.

Secondary key An attribute or combination of attributes used

strictly for data retrieval purposes.

Foreign Key - An attribute whose values match primary key values

in the related table

43

44

Integrity rules

Relational Data Manipulation


Relational tables are sets.

Entity integrity

primary key can never be a null value


used to identify a unique row in a relational table
its value must always be specified.
insert, update, and delete operations maintain the
uniqueness and existence of all primary keys.

Rows of the tables can be considered as elements of


the set
Operations that can be performed on sets can be
done on relational tables.

Referential integrity

A foreign key, must either be null or match the values


in the relational table in which that foreign key is a
primary key.

45

46