Vous êtes sur la page 1sur 66

SPECIAL TRAINING

SPECIAL

TRAINING

Database

Database

Concepts and

Concepts and

Definition of

Definition of

Terms

Terms

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

SESSION OBJECTIVE

SESSION

OBJECTIVE

This session will introduce you to the basic

This session will introduce you to the basic

concepts and terminologies used in

concepts and terminologies used in

Relational Analysis and Design.

Relational Analysis and Design.

Database Concepts Database Concepts and and Definition Definition of of Terms Terms SESSION OBJECTIVE SESSION OBJECTIVE

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

What isis aa Database

What

Database ??

A shared collection of logically related data

A shared collection of logically related data

(and a description of this data) designed to

(and a description of this data) designed to

meet the information needs of an

meet the information needs of an

organization.

organization.

Database Concepts Database Concepts and and Definition Definition of of Terms Terms is is a a
Database Database
Database
Database

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

What isis aa DBMS

What

DBMS ??

A database management system (DBMS) is

A database management system (DBMS) is

a software system that enables users to

a software system that enables users to

define, create and maintain the database

define, create and maintain the database

and which provides controlled access to this

and which provides controlled access to this

database.

database.

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

What isis aa Table

What

Table ??

A table is a 2-dimensional representation of

A table is a 2-dimensional representation of

data consisting of one or more columns, and

data consisting of one or more columns, and

zero or more rows.

zero or more rows.

Database Concepts Database Concepts and and Definition Definition of of Terms Terms is is a a

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Example

Example

COURSE

COURSE

COURSE

COURSE

CODE

CODE

COURSE

COURSE

DESCRIPTION

DESCRIPTION

BSCS

BSCS

BSIT

BSIT

BSA

BSA

BSC

BSC

COMPUTER

COMPUTER SCIENCE

SCIENCE

INFORMATION TECHNOLOGY

INFORMATION

TECHNOLOGY

ACCOUNTANCY

ACCOUNTANCY

COMMERCE

COMMERCE

The name of the table is COURSE. It has two columns

The name of the table is COURSE. It has two columns

and four rows. The column names are Course Code and

and four rows. The column names are Course Code and

Course Description.

Course Description.

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Table Naming

Table

Naming Conventions

Conventions

✔ ✔ Table Table names names must must be be unique. unique.

To avoid ambiguity in specifying a table, no two tables can have the

To avoid ambiguity in specifying a table, no two tables can have the

same name within a data model (database).

same name within a data model (database).

✔ ✔ Column Column names names must must be be unique unique within within a a

table

table

Each column within a table must have a unique name. However,

Each column within a table must have a unique name. However,

columns from different tables can have the same name and in fact,

columns from different tables can have the same name and in fact,

desirable to clearly establish relations between tables.

desirable to clearly establish relations between tables.

✔ ✔ Rows Rows must must be be unique unique

Rows, considered in their entirety, must be distinct from one

Rows, considered in their entirety, must be distinct from one

another.

another.

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

 

COURSE

COURSE

COURSE

COURSE

CODE

CODE

COURSE

COURSE

DESCRIPTION

DESCRIPTION

BSCS BSCS COMPUTER COMPUTER SCIENCE SCIENCE

BSCS

BSCS

COMPUTER

COMPUTER SCIENCE

SCIENCE

BSIT

BSIT

BSA

BSA

BSC

BSC

INFORMATION TECHNOLOGY

INFORMATION

TECHNOLOGY

ACCOUNTANCY

ACCOUNTANCY

COMMERCE

COMMERCE

 
 

STUDENT

STUDENT

STUDENT STUDENT

STUDENT

STUDENT

NUMBER

NUMBER

Example

Example

 

STUDENT

STUDENT

NAME

NAME

COURSE

COURSE

CODE

CODE

YEAR

YEAR

TUITION

TUITION

 
  • 0101 HERBERT HERBERT

  • 0202 BSCS

CARMEL

CARMEL

NICOLAI

  • 0303 BSA

NICOLAI

  • 0404 BSIT

GENE

GENE

BSCS

BSCS

BSCS

BSA

BSIT

 
  • 11 7,000.00 7,000.00

  • 22 6,500.00 6,500.00

  • 44 5,000.00 5,000.00

  • 44 8,000.00 8,000.00

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Table Naming

Table

Naming Conventions

Conventions (cont.)

(cont.)

✔ ✔ Column Column and and row row order order must must be be arbitrary. arbitrary.

Although the following tables may look different, they are actually

Although the following tables may look different, they are actually

the same. The order of the columns and rows has no

the same. The order of the columns and rows has no

significance.

significance.

STUDENT

STUDENT

STUDENT

STUDENT

STUDENT

STUDENT

NUMBER

NUMBER

STUDENT

STUDENT

NAME

NAME

COURSE

COURSE

CODE

CODE

YEAR

YEAR

 

COURSE

COURSE

CODE

CODE

STUDENT

STUDENT

NUMBER

NUMBER

YEAR

YEAR

STUDENT

STUDENT

NAME

NAME

 
  • 0101 HERBERT HERBERT

  • 0202 BSCS

CARMEL

CARMEL

NICOLAI

  • 0303 BSA

NICOLAI

  • 0404 BSIT

GENE

GENE

BSCS

BSCS

BSCS

BSA

BSIT

 
  • 11 BSA BSA

  • 22 BSIT BSIT

  • 44 BSCS BSCS

  • 44 BSCS BSCS

0303

0404

0202

0101

 
  • 44 NICOLAI NICOLAI

  • 44 GENE GENE

  • 22 CARMEL CARMEL

    • 11 HERBERT HERBERT

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Table Naming

Table

Naming Conventions

Conventions (cont.)

(cont.)

Each cell of the table contains exactly one

Each cell of the table contains exactly one

atomic (single) value.

atomic (single) value.

Since each cell should contain only one value, it is illegal to store

Since each cell should contain only one value, it is illegal to store

two year levels for a single student in a single cell (year).

two year levels for a single student in a single cell (year).

STUDENT

STUDENT

STUDENT

STUDENT

NUMBER

NUMBER

STUDENT

STUDENT

NAME

NAME

COURSE

COURSE

CODE

CODE

YEAR

YEAR

 
  • 0101 HERBERT HERBERT CARMEL CARMEL

  • 0202 BSCS

NICOLAI

  • 0303 BSA

NICOLAI

  • 0404 BSIT

GENE

GENE

BSCS

BSCS

BSCS

BSA

BSIT

11 // 22

22 // 33

44

44

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Null Values

Null

Values

Def. A missing or unknown

Def. A missing or unknown

value of a column of a table.

value of a column of a table.

Null Values

Null

Values Naming

Naming Conventions

Conventions

✔ ✔ Nulls Nulls are are not not the the same same as as blanks. blanks.

A value of a null is unknown.

A value of a null is unknown.

✔ ✔ Nulls Nulls are are not not the the same same as as zeros. zeros.

You cannot perform arithmetic operations on nulls.

You cannot perform arithmetic operations on nulls.

✔ ✔ NN NN means means no no nulls nulls allowed. allowed.

Why should some columns not allow nulls?

Why should some columns not allow nulls?

(Tuition Fees, Student Number, Subject Code, Course Code)

(Tuition Fees, Student Number, Subject Code, Course Code)

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Example

Example

on Nulls

on Nulls

COURSE

COURSE

COURSE

COURSE

CODE

CODE

 

COURSE

COURSE

DESCRIPTION

DESCRIPTION

   

NNNN

 

NNNN

BSCS

BSCS

BSIT

BSIT

BSA

BSA

 

COMPUTER

COMPUTER SCIENCE

SCIENCE

INFORMATION TECHNOLOGY

INFORMATION

TECHNOLOGY

ACCOUNTANCY

ACCOUNTANCY

 

STUDENT

STUDENT

STUDENT

STUDENT

NUMBER

NUMBER

STUDENT

STUDENT

NAME

NAME

COURSE

COURSE

CODE

CODE

YEAR

YEAR

TUITION

TUITION

NNNN

NNNN

     
  • 0202 CARMEL

  • 0303 NICOLAI

  • 0101 HERBERT HERBERT CARMEL NICOLAI

BSCS

BSCS

BSCS

BSCS

11

22

44

7,000.00

7,000.00

5,000.00

5,000.00

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Duplicate Values

Duplicate

Values

When a value in a column matches exactly

When a value in a column matches exactly

another value in the same column, it is called a

another value in the same column, it is called a

duplicate value.

duplicate value.

✔ ✔ ND ND means means no no duplicates duplicates allowed. allowed.

Duplicate rows are not allowed. However, duplicate values in

Duplicate rows are not allowed. However, duplicate values in

particular columns of a table are not at all uncommon.

particular columns of a table are not at all uncommon.

By placing ND below a column heading, it will prohibit duplicate

By placing ND below a column heading, it will prohibit duplicate

values in that column. To prevent duplicate values in groups of

values in that column. To prevent duplicate values in groups of

columns, suffix ND with a number, e.g. ND1, ND2, ND3, etc.

columns, suffix ND with a number, e.g. ND1, ND2, ND3, etc.

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Example

Example

on

on

Duplicate

Duplicate

Values

Values

COURSE

COURSE

COURSE

COURSE

CODE

CODE

 

COURSE

COURSE

DESCRIPTION

DESCRIPTION

   

NN, NDND

NN,

 

NN, NDND

NN,

BSCS

BSCS

BSIT

BSIT

BSA

BSA

 

COMPUTER

COMPUTER SCIENCE

SCIENCE

INFORMATION TECHNOLOGY

INFORMATION

TECHNOLOGY

ACCOUNTANCY

ACCOUNTANCY

 

STUDENT

STUDENT

STUDENT

STUDENT

NUMBER

NUMBER

STUDENT

STUDENT

NAME

NAME

COURSE

COURSE

CODE

CODE

YEAR

YEAR

TUITION

TUITION

NN, NDND

NN,

NN, ND1

NN,

ND1

ND1

ND1

   
  • 0202 CARMEL

  • 0303 NICOLAI

  • 0101 HERBERT HERBERT CARMEL NICOLAI

BSCS

BSCS

BSCS

BSCS

11

22

44

7,000.00

7,000.00

5,000.00

5,000.00

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Changeable

Changeable Values

Values

A value in a table that may vary over time is

A value in a table that may vary over time is

called a changeable value.

called a changeable value.

✔ ✔ NC NC means means no no changes changes allowed. allowed.

Can student numbers in a table be changed?

Can student numbers in a table be changed?

Place NC below the column heading to prevent changes on the

Place NC below the column heading to prevent changes on the

values in that column.

values in that column.

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Example

Example

on

on

Changeable

Changeable

Values

Values

COURSE

COURSE

COURSE

COURSE

CODE

CODE

 

COURSE

COURSE

DESCRIPTION

DESCRIPTION

   

NN,ND,NC

NN,ND,NC

 

NN, NDND

NN,

BSCS

BSCS

BSIT

BSIT

BSA

BSA

 

COMPUTER

COMPUTER SCIENCE

SCIENCE

INFORMATION TECHNOLOGY

INFORMATION

TECHNOLOGY

ACCOUNTANCY

ACCOUNTANCY

 

STUDENT

STUDENT

STUDENT

STUDENT

NUMBER

NUMBER

STUDENT

STUDENT

NAME

NAME

COURSE

COURSE

CODE

CODE

YEAR

YEAR

TUITION

TUITION

NN,ND,NC

NN,ND,NC

NN, ND1

NN,

ND1

ND1

ND1

   
  • 0101 HERBERT

  • 0202 CARMEL

  • 0303 NICOLAI

HERBERT

CARMEL

NICOLAI

BSCS

BSCS

BSCS

BSCS

11

22

44

7,000.00

7,000.00

5,000.00

5,000.00

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Primary Keys

Primary

Keys

The column or group of columns whose values

The column or group of columns whose values

uniquely identify each row of that table is called

uniquely identify each row of that table is called

the primary key.

the primary key.

Primary Key

Primary

Key Values

Values Naming

Naming Conventions

Conventions

✔ ✔ Every Every table table must must have have a a primary primary key. key.

✔ ✔ Every Every table table must must have have only only one one primary primary

key.

key.

✔ ✔ PK PK means means primary primary key. key.

Place PK below the heading of one or more columns which will serve

Place PK below the heading of one or more columns which will serve

as the primary key.

as the primary key.

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Constraints

Constraints onon Primary

Primary Keys

Keys

Primary key values must never be null.

Primary key values must never be null.

PK implies NN (Entity Integrity)

PK implies NN (Entity Integrity)

✔ ✔ Primary Primary key key values values must must never never be be duplicated. duplicated.

PK implies ND

PK implies ND

✔ ✔ Primary Primary key key values values must must never never be be changed. changed.

PK implies NC

PK implies NC

Primary keys do not influence column order.

Primary keys do not influence column order.

✔ ✔ Primary Primary keys keys do do not not influence influence row row order. order.

✔ ✔ Primary Primary keys keys do do not not influence influence row row access. access.

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Other Primary Keys

Other Primary Keys

Notations

Notations

SA means system-assigned

SA means system-assigned

Mark a column with SA, in addition to PK if the values are

Mark a column with SA, in addition to PK if the values are

automatically generated by the system.

automatically generated by the system.

✔ ✔ UA UA means means user-assigned user-assigned

Mark a column with UA, in addition to PK, if the values of the primary

Mark a column with UA, in addition to PK, if the values of the primary

key are assigned by the user.

key are assigned by the user.

COURSE

COURSE

COURSE

COURSE

CODE

CODE

COURSE

COURSE

DESCRIPTION

DESCRIPTION

PK, UAUA

PK,

NN, NDND

NN,

BSCS

BSCS

BSIT

BSIT

BSA

BSA

COMPUTER

COMPUTER SCIENCE

SCIENCE

INFORMATION TECHNOLOGY

INFORMATION

TECHNOLOGY

ACCOUNTANCY

ACCOUNTANCY

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Foreign Keys

Foreign

Keys

A column or group of columns that is a primary

A column or group of columns that is a primary

key elsewhere is called a foreign key.

key elsewhere is called a foreign key.

Foreign Key

Foreign

Key Rules

Rules and

and Constraints

Constraints

FK mean foreign key

FK mean foreign key

Multi-column foreign keys can be numbered, e.g. FK1, FK2, etc.

Multi-column foreign keys can be numbered, e.g. FK1, FK2, etc.

Foreign key values might be null.

Foreign key values might be null.

Foreign key columns can contain duplicate

Foreign key columns can contain duplicate

values.

values.

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Foreign Key

Foreign

Key Rules

Rules and

and Constraints

Constraints (cont.)

(cont.)

FK values must refer to existing PK values

FK values must refer to existing PK values

(Referential Integrity)

(Referential Integrity)

COURSE

COURSE

COURSE

COURSE

CODE

CODE

COURSE

COURSE

DESCRIPTION

DESCRIPTION

PK,UA

PK,UA

NN, NDND

NN,

BSCS

BSCS

BSIT

BSIT

BSA

BSA

COMPUTER

COMPUTER SCIENCE

SCIENCE

INFO. TECHNOLOGY

INFO.

TECHNOLOGY

ACCOUNTANCY

ACCOUNTANCY

STUDENT

STUDENT

STUDENT

STUDENT

NUMBER

NUMBER

STUDENT

STUDENT

NAME

NAME

COURSE

COURSE

CODE

CODE

YEAR

YEAR

TUITION

TUITION

PK,SA

PK,SA

NN, ND1

NN,

ND1

FK,ND1

FK,ND1

   
  • 0101 HERBERT

  • 0202 CARMEL

HERBERT

CARMEL

BSCS

BSCS

11

22

7,000.00

7,000.00

  • 0303 NICOLAI

  • 0404 LOUIE

NICOLAI

LOUIE

BSA

BSA

ABAB

44

33

5,000.00

5,000.00

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Derivative Data

Derivative

Data

Data that is calculated from data defined

Data that is calculated from data defined

elsewhere in a model is called derivative data.

elsewhere in a model is called derivative data.

✔ ✔ DD DD means means derivative derivative data. data.

✔ ✔ DD DD is is redundant redundant data. data.

Derivative data should only be included in a model when severe

Derivative data should only be included in a model when severe

performance problems dictate its necessity.

performance problems dictate its necessity.

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

Derivative Data

Derivative

Data Example

Example

COURSE

COURSE

COURSE

COURSE

CODE

CODE

COURSE

COURSE

DESCRIPTION

DESCRIPTION

STUDENT

STUDENT

COUNT

COUNT

PK,UA

PK,UA

NN, NDND

NN,

DDDD

BSCS

BSCS

BSIT

BSIT

BSA

BSA

COMPUTER

COMPUTER SCIENCE

SCIENCE

INFO. TECHNOLOGY

INFO.

TECHNOLOGY

ACCOUNTANCY

ACCOUNTANCY

11

2121

00

The Student Count column of the Course table is a derived data; the

The Student Count column of the Course table is a derived data; the

values in this column are calculated from the information resident in the

values in this column are calculated from the information resident in the

Student table.

Student table.

SPECIAL TRAINING

SPECIAL

TRAINING

Basic

Basic

Relational

Relational

Analysis

Analysis

Basic Relational

Basic

Relational Analysis

Analysis

SESSION OBJECTIVE

SESSION

OBJECTIVE

This session will introduce you to the steps,

This session will introduce you to the steps,

procedures and rules used in basic relational

procedures and rules used in basic relational

analysis and design.

analysis and design.

Basic Relational Basic Relational Analysis Analysis SESSION OBJECTIVE SESSION OBJECTIVE This session will introduce you to

Basic Relational

Basic

Relational Analysis

Analysis

What isis anan Entity

What

Entity ??

An entity is a distinct object (a person, place

An entity is a distinct object (a person, place

or thing, concept or event) in the organization

or thing, concept or event) in the organization

that is to be represented in the database.

that is to be represented in the database.

Basic Relational

Basic

Relational Analysis

Analysis

Steps

Steps inin Modeling

Modeling Entities

Entities

✔ ✔ DISCOVER DISCOVER AN AN ENTITY ENTITY

➣ ➣ Ask: Ask:

What person, place or thing do you want to keep track of?

What person, place or thing do you want to keep track of?

➣ ➣ Concentrate Concentrate on on nouns nouns

More often, entities are obvious physical objects. Sometimes, they

More often, entities are obvious physical objects. Sometimes, they

are nothing more than a concept or idea.

are nothing more than a concept or idea.

➣ ➣ Beware Beware of of attributes attributes in in disguise disguise

Entities stand on their own; attributes have meaning only in the

Entities stand on their own; attributes have meaning only in the

context of the entities which they describe. Entities have attributes;

context of the entities which they describe. Entities have attributes;

attributes have no characteristics they can call their own.

attributes have no characteristics they can call their own.

Basic Relational

Basic

Relational Analysis

Analysis

✔ ✔ DEFINE DEFINE THE THE SCOPE SCOPE OF OF THE THE ENTITY ENTITY

➣ ➣ Verify Verify user user interest interest

Users often mention entities that are not really within the scope of a

Users often mention entities that are not really within the scope of a

model. They may be interested in a particular entity, but not

model. They may be interested in a particular entity, but not

enough to warrant keeping track of it. In which case, exclude it from

enough to warrant keeping track of it. In which case, exclude it from

the model.

the model.

➣ ➣ Concentrate Concentrate on on types types not not occurrences occurrences

Student instead of Carmel or Herbert.

Student instead of Carmel or Herbert.

➣ ➣ Establish Establish the the appropriate appropriate level level of of detail detail

When a user says Part, he may refer to the kinds of part (e.g. hard

When a user says Part, he may refer to the kinds of part (e.g. hard

disk, video card, etc.) rather than a specific part identified by Serial

disk, video card, etc.) rather than a specific part identified by Serial

No. 1234. In this case, you may want to use Part Kind instead of

No. 1234. In this case, you may want to use Part Kind instead of

Part as the entity name.

Part as the entity name.

Basic Relational

Basic

Relational Analysis

Analysis

✔ ✔ DETERMINE DETERMINE THE THE PRIMARY PRIMARY KEY KEY

➣ ➣ Ask: Ask:

What uniquely identifies the entity from another?

What uniquely identifies the entity from another?

➣ ➣ Check Check for for nulls nulls

Make sure that the potential primary key is never null.

Make sure that the potential primary key is never null.

➣ ➣ Check Check for for duplicates duplicates

Make sure that the proposed primary key is always unique.

Make sure that the proposed primary key is always unique.

➣ ➣ Check Check for for changes changes

The proposed primary key values must never be changed.

The proposed primary key values must never be changed.

➣ ➣ System-assign System-assign if if necessary necessary

The proposed primary key values should preferably be system-

The proposed primary key values should preferably be system-

assigned. If no key exists, assign a code or number column as the

assigned. If no key exists, assign a code or number column as the

primary key of the entity.

primary key of the entity.

Basic Relational

Basic

Relational Analysis

Analysis

✔ ✔ DOCUMENT DOCUMENT THE THE ENTITY ENTITY IN IN TABLE TABLE FORM FORM

Draw the table and assign: entity name, column/primary keys,

Draw the table and assign: entity name, column/primary keys,

PK/SA or UA, sample data or occurrences.

PK/SA or UA, sample data or occurrences.

COURSE

COURSE

COURSE

COURSE

NUMBER

NUMBER

PK, UAUA

PK,

BSCS

BSCS

BSIT

BSIT

BSA

BSA

  • Entity Entity names

names

  • Primary Primary key

key names

names

  • and SASA or

PKPK and

or UAUA

  • Sample Sample occurrences

occurrences

STUDENT STUDENT

STUDENT

STUDENT

STUDENT

STUDENT

NUMBER NUMBER

NUMBER

NUMBER

SASA PK,

PK, SASA

PK,

01

01

02 02

02

02

03

03

Basic Relational

Basic

Relational Analysis

Analysis

Example: Modeling

Example:

Modeling Entities

Entities

“Well, Ma and I and the other three-hundred employees have been running

“Well, Ma and I and the other three-hundred employees have been running

this here little health food store just fine without a computer, but we reckon

this here little health food store just fine without a computer, but we reckon

we’d better keep up with the times if we’re gonna keep up with the Joneses,

we’d better keep up with the times if we’re gonna keep up with the Joneses,

know what I mean? I’m sure you do. Yes, you can assign Employee Numbers

know what I mean? I’m sure you do. Yes, you can assign Employee Numbers

if you’d like to…

if you’d like to…

Anyway, we need to keep track of all these different kinds of items - wheat

Anyway, we need to keep track of all these different kinds of items - wheat

germ, Vitamin E, chocolate covered granola - that’s a big seller. You better

germ, Vitamin E, chocolate covered granola - that’s a big seller. You better

give ‘em all numbers, ‘cause we’ve got more kinds of items than you can

give ‘em all numbers, ‘cause we’ve got more kinds of items than you can

shake a stick at. And we need to know which items are sold in which stores,

shake a stick at. And we need to know which items are sold in which stores,

and which aren’t. Be nice to know how many each store’s got on hand, too.

and which aren’t. Be nice to know how many each store’s got on hand, too.

Excuse me? No, we don’t have numbers for the stores, but if you want to give

Excuse me? No, we don’t have numbers for the stores, but if you want to give

‘em some, its OK with Ma and me

‘em some, its OK with Ma and me

..

..

Did ya know we have stores in three different cities now? Youbetcha. And

Did ya know we have stores in three different cities now? Youbetcha. And

we’re thinking of branching out to other key cities before too long.”

we’re thinking of branching out to other key cities before too long.”

Basic Relational

Basic

Relational Analysis

Analysis

Example: Modeling

Example:

Modeling Entities

Entities

EMPLOYEE

EMPLOYEE

STORE

STORE

EMPLOYEE

EMPLOYEE

NUMBER

NUMBER

 

STORE

STORE

CODE

CODE

PK, SASA

PK,

PK, SASA

PK,

1 1

1 1

  • 2 2 2

2

  • 3 3 3

3

ITEM

ITEM

ITEM

ITEM

CODE

CODE

PK, UAUA

PK,

456DFG1

456DFG1

264SG45

264SG45

3FGH4D

3FGH4D

CITY

CITY

CITY

CITY

CODE

CODE

PK, UAUA

PK,

CBU

CBU

MLA

MLA

DVO

DVO

Basic Relational

Basic

Relational Analysis

Analysis

Example: Modeling

Example:

Modeling Entities

Entities

“It seems we’ve got more employees out in the field than ever before.

“It seems we’ve got more employees out in the field than ever before.

Almost 200 in area N, the north area, and nearly 100 in the south - area S.

Almost 200 in area N, the north area, and nearly 100 in the south - area S.

The eastern area, E, is still the largest though. It’s alright with us if you

The eastern area, E, is still the largest though. It’s alright with us if you

want to number the employees.

want to number the employees.

Good thing our customer base is growing as well. Fourteen new

Good thing our customer base is growing as well. Fourteen new

customers in the western area alone. You want to number the customers

customers in the western area alone. You want to number the customers

too? Well, why not?

too? Well, why not?

  • I I

understand the boss has come up with a classification scheme to keep

understand the boss has come up with a classification scheme to keep

track of what kind of customers are out there, and what kind of experience

track of what kind of customers are out there, and what kind of experience

we employees have - Class Codes, I think he calls them. Things like B for

we employees have - Class Codes, I think he calls them. Things like B for

Banks, G for government agencies, H for hospitals, and so on…”

Banks, G for government agencies, H for hospitals, and so on…”

Basic Relational

Basic

Relational Analysis

Analysis

Example: Modeling

Example:

Modeling Entities

Entities

EMPLOYEE

EMPLOYEE

AREA

AREA

EMPLOYEE

EMPLOYEE

NUMBER

NUMBER

 

AREA

AREA

CODE

CODE

PK, SASA

PK,

PK, UAUA

PK,

1 1

S

S

  • 2 2 W

W

  • 3 3 E

E

CUSTOMER

CUSTOMER

CUSTOMER

CUSTOMER

CODE

CODE

PK, UAUA

PK,

C451

C451

C342

C342

C343

C343

CLASS

CLASS

CLASS

CLASS

CODE

CODE

PK, UAUA

PK,

B

B

G

G

H

H

SPECIAL TRAINING

SPECIAL

TRAINING

Workshop:

Workshop:

Modeling

Modeling

Entities

Entities

Relational Analysis:

Relational

Analysis: Modeling

Modeling Relations

Relations

What isis aa Relation

What

Relation ??

A mode of being, an association, an action or

A mode of being, an association, an action or

an event that connects two or more entities

an event that connects two or more entities

together is called a relation.

together is called a relation.

Relational Analysis: Relational Analysis: Modeling Modeling Relations Relations is is a a Relation What ? ?

Relational Analysis:

Relational

Analysis: Modeling

Modeling Relations

Relations

Types of

Types

of Relations

Relations

One-to-One Relations

One-to-One Relations

Each occurrence of one entity can be related to zero or one, but

Each occurrence of one entity can be related to zero or one, but

no more than one occurrence of another entity.

no more than one occurrence of another entity.

One-to-Many Relations

One-to-Many Relations

Each occurrence of one entity, say X, can be related to zero, one

Each occurrence of one entity, say X, can be related to zero, one

or more occurrences of another entity, say Y; but Y can be

or more occurrences of another entity, say Y; but Y can be

related to zero or one, but no more than one occurrence of X.

related to zero or one, but no more than one occurrence of X.

Many-to-Many Relations

Many-to-Many Relations

Each occurrence of one entity, say X, can be related to zero, one

Each occurrence of one entity, say X, can be related to zero, one

or more occurrences of another entity, say Y and vice-versa.

or more occurrences of another entity, say Y and vice-versa.

Relational Analysis:

Relational

Analysis: Modeling

Modeling Relations

Relations

Steps

Steps inin Modeling

Modeling Relations

Relations

DISCOVER A RELATION

DISCOVER A RELATION

Ask:

Ask:

Is there a relation between this entity and that entity?

Is there a relation between this entity and that entity?

Focus on one relation at a time

Focus on one relation at a time

If a relation exists, document that relation in table form before

If a relation exists, document that relation in table form before

proceeding to the next.

proceeding to the next.

Exhaust all possible relations

Exhaust all possible relations

For every entity identified, check if ti has a relation with all other

For every entity identified, check if ti has a relation with all other

entities defined.

entities defined.

Relational Analysis:

Relational

Analysis: Modeling

Modeling Relations

Relations

DEFINE THE SCOPE OF THE RELATION

DEFINE THE SCOPE OF THE RELATION

Verify user interest

Verify user interest

Relations may exist that are of no use or interest to the user.

Relations may exist that are of no use or interest to the user.

EXCLUDE IT FROM THE MODEL.

EXCLUDE IT FROM THE MODEL.

Concentrate on direct relations

Concentrate on direct relations

Some relations can be derived (indirectly) from other relations.

Some relations can be derived (indirectly) from other relations.

EXCLUDE IT FROM THE MODEL.

EXCLUDE IT FROM THE MODEL.

Relational Analysis:

Relational

Analysis: Modeling

Modeling Relations

Relations

DETERMINE THE TYPE OF RELATION

DETERMINE THE TYPE OF RELATION

ASK 2 Questions:

ASK 2 Questions:

Can entity A be related to more than one entity B?

Can entity A be related to more than one entity B?

Can entity B be related to more than one entity A?

Can entity B be related to more than one entity A?

Interpret the answers

Interpret the answers

  2 No answers - one-to-one relation

2 No answers - one-to-one relation

  1 Yes / 1 No answer - one-to-many relation

1 Yes / 1 No answer - one-to-many relation

  2 Yes answers - many-to-many relation

2 Yes answers - many-to-many relation

Relational Analysis:

Relational

Analysis: Modeling

Modeling Relations

Relations

DOCUMENT THE RELATION IN TABLE

DOCUMENT THE RELATION IN TABLE

FORM

FORM

One-to-one relation

One-to-one relation

Place the foreign key, no duplicates allowed (FK,ND) into the

Place the foreign key, no duplicates allowed (FK,ND) into the

smaller table.

smaller table.

One-to-many relation

One-to-many relation

Place the foreign key, allowing duplicates (FK) into the table on the

Place the foreign key, allowing duplicates (FK) into the table on the

YES side of the relation.

YES side of the relation.

Many-to-many relation

Many-to-many relation

Draw a new table with a multi-column primary key consisting of two

Draw a new table with a multi-column primary key consisting of two

single-column foreign key.

single-column foreign key.

Relational Analysis:

Relational

Analysis: Modeling

Modeling Relations

Relations

One-to-one Situation

One-to-one

Situation

In a taxi-service company, each driver is assigned to one

In a taxi-service company, each driver is assigned to one

and only one unit. On the other hand, each unit is also

and only one unit. On the other hand, each unit is also

assigned to one and only one driver.

assigned to one and only one driver.

DRIVER

DRIVER

UNIT

UNIT

Driver

Driver

Number

Number

 

Unit

Unit

Number

Number

Driver

Driver

Number

Number

PK,UA

PK,UA

PK,UA

PK,UA

FK,ND

FK,ND

D1

D1

D2

D2

D3

D3

T201

T201

T202

T202

D1

D1

D3

D3

The relation is

The relation is

placed on the

placed on the

unit side since

unit side since

there are

there are

fewer units

fewer units

than drivers.

than drivers.

Relational Analysis:

Relational

Analysis: Modeling

Modeling Relations

Relations

One-to-many Situation

One-to-many

Situation

A student is allowed to take only one course. However,

A student is allowed to take only one course. However,

there could be more than one student enrolled in each of

there could be more than one student enrolled in each of

the courses.

the courses.

COURSE COURSE

STUDENT

STUDENT

Course

Course

Number

Number

 

Student

Student

Number

Number

Course

Course

Number

Number

PK,UA

PK,UA

PK,UA

PK,UA

FK, NN

FK, NN

BSIT

BSIT

BSCS

BSCS

BSA

BSA

S01

S01

S02

S02

S03

S03

BSIT

BSIT

BSIT

BSIT

BSCS

BSCS

The relation is

The relation is

placed on the

placed on the

student entity

student entity

being in the

being in the

YES side of

YES side of

the relation.

the relation.

Relational Analysis:

Relational

Analysis: Modeling

Modeling Relations

Relations

Many-to-many Situation

Many-to-many

Situation

STUDENT

STUDENT

Student

Student

Number

Number

PK,UA

PK,UA

S01

S01

S02

S02

S03

S03

SUBJECT

SUBJECT

Subject

Subject

Code

Code

PK,UA

PK,UA

CS11

CS11

CS12

CS12

CS13

CS13

STUDENT/SUBJECT

STUDENT/SUBJECT

Student

Student

Number

Number

Subject

Subject

Code

Code

PK,FK

PK,FK

PK,FK

PK,FK

S01

S01

S01

S01

S02

S02

CS11

CS11

CS12

CS12

CS11

CS11

A new table is created to

A new table is created to

implement the many-to-many

implement the many-to-many

relation.

relation.

Relational Analysis:

Relational

Analysis: Modeling

Modeling Relations

Relations

Using the

Using the

Relations

Relations

Matrix

Matrix

STAFF STAFF -- -- 1:M1:M -- CITY CITY 1:1 1:1 ITEM M:M ITEM M:M STORE STORE
STAFF
STAFF
--
--
1:M1:M
--
CITY
CITY
1:1
1:1
ITEM
M:M
ITEM
M:M
STORE
STORE
STAFF
STAFF
CITY
CITY
ITEM
ITEM
STORE
STORE

SPECIAL TRAINING

SPECIAL

TRAINING

Workshop:

Workshop:

Modeling

Modeling

Relations

Relations

Relational Analysis:

Relational

Analysis: Modeling

Modeling Attributes

Attributes

What isis anan Attribute

What

Attribute ??

A qualifier of an entity or a relation describing

A qualifier of an entity or a relation describing

its character, quantity, degree or extent is

its character, quantity, degree or extent is

called an attribute.

called an attribute.

Relational Analysis: Relational Analysis: Modeling Modeling Attributes Attributes is is an an Attribute What ? ?

Relational Analysis:

Relational

Analysis: Modeling

Modeling Attributes

Attributes

Steps

Steps inin Modeling

Modeling Attributes

Attributes

DISCOVER AN ATTRIBUTE

DISCOVER AN ATTRIBUTE

Ask:

Ask:

What other characteristics of [entity or relation] are you interested

What other characteristics of [entity or relation] are you interested

in?

in?

Focus on one attribute at a time

Focus on one attribute at a time

If an attribute exists, model it in table form before proceeding to

If an attribute exists, model it in table form before proceeding to

the next attribute.

the next attribute.

Relational Analysis:

Relational

Analysis: Modeling

Modeling Attributes

Attributes

Steps

Steps inin Modeling

Modeling Attributes

Attributes

DEFINE THE SCOPE OF THE ATTRIBUTE

DEFINE THE SCOPE OF THE ATTRIBUTE

Verify user interest

Verify user interest

Some attributes are obvious, reasonable, and easy to represent

Some attributes are obvious, reasonable, and easy to represent

in table form; but they are of no use or interest to the user.

in table form; but they are of no use or interest to the user.

EXCLUDE THEM FROM THE MODEL.

EXCLUDE THEM FROM THE MODEL.

Concentrate on real attributes

Concentrate on real attributes

Check whether the proposed attribute already exists (perhaps in

Check whether the proposed attribute already exists (perhaps in

other form) or can be derived from other attributes in the model.

other form) or can be derived from other attributes in the model.

Relational Analysis:

Relational

Analysis: Modeling

Modeling Attributes

Attributes

Steps

Steps inin Modeling

Modeling Attributes

Attributes

DEFINE THE KEY OF THE ATTRIBUTE

DEFINE THE KEY OF THE ATTRIBUTE

This steps determines where in a model an attribute is

This steps determines where in a model an attribute is

to be placed.

to be placed.

The Prepositional Phrase Method

The Prepositional Phrase Method

Explicit Prepositional Phrase

Explicit Prepositional Phrase

The user explicitly says it. Example: the name of each student.

The user explicitly says it. Example: the name of each student.

Implicit Prepositional Phrase

Implicit Prepositional Phrase

The user did not say it; but it is implied. Example: the course of

The user did not say it; but it is implied. Example: the course of

each student.

each student.

Relational Analysis:

Relational

Analysis: Modeling

Modeling Attributes

Attributes

Steps

Steps inin Modeling

Modeling Attributes

Attributes

DEFINE THE KEY OF THE ATTRIBUTE

DEFINE THE KEY OF THE ATTRIBUTE

Possessives

Possessives

Shorthand for prepositional phrases. Example: the student’s

Shorthand for prepositional phrases. Example: the student’s

birthday.

birthday.

The Normalization Process

The Normalization Process

Invented by Dr. Edgar F. Codd, the father of relational database.

Invented by Dr. Edgar F. Codd, the father of relational database.

The Intuitive Approach

The Intuitive Approach

The key of any given attribute is very obvious.

The key of any given attribute is very obvious.

Relational Analysis:

Relational

Analysis: Modeling

Modeling Attributes

Attributes

Steps

Steps inin Modeling

Modeling Attributes

Attributes

DOCUMENT THE ATTRIBUTE IN TABLE

DOCUMENT THE ATTRIBUTE IN TABLE

FORM

FORM

Ask about nulls

Ask about nulls

If a value is required at all times, mark the column NN.

If a value is required at all times, mark the column NN.

Ask about duplicates

Ask about duplicates

If all the values in the column must always be unique, mark the

If all the values in the column must always be unique, mark the

column ND.

column ND.

Minimize derivative data

Minimize derivative data

If the values in the column can always be derived from data

If the values in the column can always be derived from data

elsewhere in the model, mark the column DD.

elsewhere in the model, mark the column DD.

SPECIAL TRAINING

SPECIAL

TRAINING

Workshop:

Workshop:

Modeling

Modeling

Attributes

Attributes

Normalization

Normalization

Normalization

Normalization

Process

Process

Process

Process

SPECIAL TRAINING

SPECIAL

TRAINING

Database Concepts

Database

Concepts and

and Definition

Definition of

of Terms

Terms

SESSION OBJECTIVE

SESSION

OBJECTIVE

This session will introduce you to the the

This session will introduce you to the the

process of normalization. It will present the

process of normalization. It will present the

purpose of normalization and will teach you

purpose of normalization and will teach you

how to define normal forms for tables and

how to define normal forms for tables and

how to undertake the normalization

how to undertake the normalization

process.

process.

The Process

The

Process of

of Normalization:

Normalization:

Redundancy and

Redundancy

and Update

Update Anomalies

Anomalies

COURSE

COURSE

 

STUDENT

STUDENT

 

COURSE

COURSE

CODE

CODE

COURSE

COURSE

DESCRIPTION

DESCRIPTION

   

STUDENT

STUDENT

NUMBER

NUMBER

STUDENT

STUDENT

NAME

NAME

COURSE

COURSE

CODE

CODE

YEAR

YEAR

TUITION

TUITION

PK, UAUA

PK,

NN, NDND

NN,

PK, SASA

PK,

NN, ND1

NN,

ND1

FK,ND1

FK,ND1

   

BSCS

BSCS

BSIT

BSIT

BSA

BSA

COMPUTER

COMPUTER SCIENCE

SCIENCE

INFO. TECHNOLOGY

INFO.

TECHNOLOGY

ACCOUNTANCY

ACCOUNTANCY

0101

0202

0303

HERBERT

HERBERT

CARMEL

CARMEL

NICOLAI

NICOLAI

BSCS

BSCS

BSCS

BSCS

BSA

BSA

11

22

44

7,000.00

7,000.00

5,000.00

5,000.00

 

STUDENT_COURSE

STUDENT_COURSE

 

STUDENT

STUDENT

NUMBER

NUMBER

STUDENT

STUDENT

NAME

NAME

YEAR

YEAR

TUITION

TUITION

COURSE

COURSE

CODE

CODE

COURSE

COURSE

DESCRIPTION

DESCRIPTION

 

PK, SASA

PK,

NNNN

NNNN

 

NNNN

NNNN

NNNN

0101

0202

0303

HERBERT

HERBERT

CARMEL

CARMEL

NICOLAI

NICOLAI

 

11

22

44

7,000.00

7,000.00

5,000.00

5,000.00

BSCS

BSCS

BSIT

BSIT

BSA

BSA

COMPUTER

COMPUTER SCIENCE

SCIENCE

INFO. TECHNOLOGY

INFO.

TECHNOLOGY

ACCOUNTANCY

ACCOUNTANCY

Normalization // Update

Normalization

Update Anomalies:

Anomalies:

Insertion Anomalies

Insertion

Anomalies

STUDENT_COURSE

STUDENT_COURSE

STUDENT

STUDENT

NUMBER

NUMBER

STUDENT

STUDENT

NAME

NAME

YEAR

YEAR

TUITION

TUITION

COURSE

COURSE

CODE

CODE

COURSE

COURSE

DESCRIPTION

DESCRIPTION

PK, SASA

PK,

NN, ND1

NN,

ND1

   

NN,ND,NC

NN,ND,NC

NN, NDND

NN,

  • 0101 HERBERT

  • 0202 CARMEL

  • 0303 NICOLAI

HERBERT

CARMEL

NICOLAI

 
  • 11 BSCS

7,000.00

7,000.00

  • 22 BSIT

5,000.00

  • 44 BSA

5,000.00

BSCS

BSIT

BSA

COMPUTER

COMPUTER SCIENCE

SCIENCE

INFO. TECHNOLOGY

INFO.

TECHNOLOGY

ACCOUNTANCY

ACCOUNTANCY

To insert the details of new students in Student_Course

To insert the details of new students in Student_Course

table, we must include the details of the courses at which

table, we must include the details of the courses at which

the students are enrolled.

the students are enrolled.

For example, to insert the details of new BSIT student, we must enter the

For example, to insert the details of new BSIT student, we must enter the