You are on page 1of 9

Module 2: Relational Database Concepts

After completing this module, you will be able to:


Define the terms associated with databases
Define the terms associated with relational databases
List the advantage of a relational database

What is a Database?
Database A collection of permanently stored data that is:

Logically related

(data relates to other data)

Shared

(many users may access data)

Protected

(access to data is controlled)

Managed

(data has integrity and value)

Win XP

Win 2000

Teradata
DATABASE

UNIX
Client

Mainframe
Client

Relational Databases
A Relational Database consists of a set of logically related tables.
A table is a two dimensional representation of data consisting of rows and
columns.
Column
EMPLOYEE
MANAGER
EMPLOYEE EMPLOYEE
NUMBER
NUMBER

Row

1006
1008
1005
1004
1007
1003

1019
1019
0801
1003
1005
0801

DEPT
NUMBER

JOB
CODE

LAST
NAME

301
301
403
401
403
401

312101
312102
431100
412101
432101
411100

Stein
Kanieski
Ryan
Johnson
Villegas
Trader

FIRST
NAME

HIRE
DATE

BIRTH
DATE

SALARY
AMOUNT

John
Carol
Loretta
Darlene
Arnando
James

861015
870201
861015
861015
870102
860731

631015
680517
650910
560423
470131
570619

3945000
3925000
4120000
4630000
5970000
4785000

The employee table has nine columns of data.


It has six rows of data - one per employee.
There is no prescribed order for the rows of the table.
There is only one row format for the entire table.
Missing data values are represented by nulls.

Primary Key
Primary Key values uniquely identify each row in a table.
EMPLOYEE
MANAGER
EMPLOYEE EMPLOYEE
NUMBER
NUMBER

DEPT
NUMBER

JOB
CODE

LAST
NAME

301
301
403
401
403
401

312101
312102
431100
412101
432101
411100

Stein
Kanieski
Ryan
Johnson
Villegas
Trader

FIRST
NAME

HIRE
DATE

BIRTH
DATE

SALARY
AMOUNT

John
Carol
Loretta
Darlene
Arnando
James

861015
870201
861015
861015
870102
860731

631015
680517
650910
560423
470131
570619

3945000
3925000
4120000
4630000
5970000
4785000

PK
1006
1008
1005
1004
1007
1003

1019
1019
0801
1003
1005
0801

In a relational model,

A Primary Key is required for every table.


Only one Primary Key is allowed in a table.
It may consist of one or more columns.
Primary Keys cannot have duplicate values.
Primary Keys cannot be NULL.
Primary Keys are considered non-changing values.

Foreign Key
Foreign Key (FK) values identify table relationships.
EMPLOYEE (partial listing)
MANAGER
EMPLOYEE EMPLOYEE
NUMBER
NUMBER

DEPT
NUMBER

JOB
CODE

PK

FK

FK

FK

1006
1008
1005
1004
1007
1003

1019
1019
0801
1003
1005
0801

301
301
403
401
403
401

312101
312102
431100
412101
432101
411100

LAST
NAME

Stein
Kanieski
Ryan
Johnson
Villegas
Trader

FIRST
NAME

HIRE
DATE

BIRTH
DATE

SALARY
AMOUNT

John
Carol
Loretta
Darlene
Arnando
James

861015
870201
861015
861015
870102
860731

631015
680517
650910
560423
470131
570619

3945000
3925000
4120000
4630000
5970000
4785000

FKs are optional - not all tables


have them
DEPARTMENT
DEPT
NUMBER

DEPARTMENT
NAME

MANAGER
BUDGET EMPLOYEE
AMOUNT NUMBER

PK
501
301
302
403
402
401
201

FK
marketing sales
research and development
product planning
education
software support
customer support
technical operations

80050000
46560000
22600000
93200000
30800000
98230000
29380000

1017
1019
1016
1005
1011
1003
1025

More than one FK is allowed per table


FKs can be made up of more than
one column

Duplicate values are allowed


Missing (NULL) values are allowed
Changes are allowed
Each FK value must exist somewhere
as a PK value

Exercise: Answering Questions with a


Relational Database
EMPLOYEE (partial listing)
MANAGER
EMPLOYEE EMPLOYEE
NUMBER
NUMBER

DEPT
NUMBER

JOB
CODE

PK

FK

FK

FK

1006
1008
1005
1004
1007
1003

1019
1019
0801
1003
1005
0801

301
301
403
401
403
401

312101
312102
431100
412101
432101
411100

LAST
NAME

Stein
Kanieski
Ryan
Johnson
Villegas
Trader

FIRST
NAME

HIRE
DATE

BIRTH
DATE

SALARY
AMOUNT

John
Carol
Loretta
Darlene
Arnando
James

861015
870201
861015
861015
870102
860731

631015
680517
650910
560423
470131
570619

3945000
3925000
4120000
4630000
5970000
4785000

DEPARTMENT
DEPT
NUMBER

DEPARTMENT
NAME

MANAGER
BUDGET EMPLOYEE
AMOUNT NUMBER

PK
501
301
302
403
402
401
201

FK
marketing sales
research and development
product planning
education
software support
customer support
technical operations

80050000
46560000
22600000
93200000
30800000
98230000
29380000

1017
1019
1016
1005
1011
1003
1025

Questions:
1. Name the department in which
James Trader works.
2. Who manages the Education
Department?
3. Identify by name an employee
who works for James Trader.
4. James Trader manages which
department?

Advantages of a Relational Database Approach


The advantages of a Relational Database compared to other database
methodologies are many.
Relational database methodology:

Is easy to use
Is easy to understand
Models the business, not the processes
Is data-driven versus application driven
Makes applications easier to build
Supports trend toward end-user computing
Is the industry standard for most large enterprises
Allows businesses to respond to changing conditions more flexibly than
other types

Review Questions
Match each term with its definition below:
___ 1.

Database

___ 2.

Table

___ 3.

Relational database

___ 4.

Primary Key

___ 5.

Null

___ 6.

Foreign Key

a
b
c
d
e
f

A set of columns which uniquely identify a row


A set of logically related tables
One or more columns that are a PK somewhere in the database
The absence of a value
A two-dimensional array of rows and columns
A collection of permanently stored data

Module 2: Review Question Answers


Match each term with its definition below:
_f_ 1.

Database

_e_ 2.

Table

_b_ 3.

Relational database

_a_ 4.

Primary Key

_d_ 5.

Null

_c_ 6.

Foreign Key

a
b
c
d
e
f

A set of columns which uniquely identify a row


A set of logically related tables
One or more columns that are a PK somewhere in the database
The absence of a value
A two-dimensional array of rows and columns
A collection of permanently stored data

You might also like