Ais Chapter 4
Ais Chapter 4
RELATIONAL
DATABASES
Prepared by : Dhelrey Janine Yoldan
Gwyneth Jane Deiparine
Archie Villar
RELATIONAL DATABASES
STUDENTS
Last First Phone Birth
Student ID Name Name Number Date
333-33-3333 Simpson Alice 333-3333 10/11/84
111-11-1111 Sanders Ned 444-4444 11/24/86
123-45-6789 Moore Artie 555-5555 04/20/85
ENTITY
All the fields containing data about one entity (one student) form a record.
❑All the fields containing data about one entity (one
student) form a record.
❑A set of all related records forms a file (student file).
❑A set of interrelated, centrally coordinated files forms a
database.
Student Class
File File
Advisor
File
DATABASE MANAGEMENT SYSTEM
DATABASE SYSTEM
❑ is the combination of the database, the DBMS, and the
application programs that access the database.
Database
Management
System
✓ Used in accounting/audit.
✓ Benefits includes:
❖ Data Integration
❖ Data Sharing
❖ Reporting Flexibility
❖ Minimal Data Redundancy and Inconsistencies
❖ Data Independence
❖ Central Management of Data
❖ Cross Functional Analysis
Database
Logical View—User A Logical View—User B
Enrollment by Class
DBMS
The operating system
Operating translates DBMS requ
System ests into instructions t
o physically retrieve d
ata from various disks
.
Database
DATABASE SYSTEM
Three levels:
❖Conceptual - shows the entire database, list of all data el
ement and its relationship.
❖External - a set of individual views on portions of the data
base
Subschema- refers to individual views
❖Internal - a low level view of the database describing how
data are accessed and stored.
Subschema--User A Subschema--User B Subschema--User C
Smith . . . A
Jones . . . B
Arnold . . .D
Cash
Receipt
❑Data Dictionary
▪ Dictionary Inputs include:
❖Records of new or deleted data elements
❖Changes in the names, description, or uses of the
existing elements
▪ Dictionary Outputs include:
❖Designing and implementing the system
❖Creating and audit trail
DATABASE SYSTEM
❑DBMS LANGUAGE
Every DBMS must perform the three basic functions of:
▪ Creating a database
The set of commands used to create the database is
called Data Definition Language (DDL) that is used to:
❖ Build the data dictionary
❖ Initialize the database
❖ Specify limitations
DATABASE SYSTEM
❑DBMS LANGUAGE
▪ Changing a database
The set of commands used to change the database is
called Data Manipulation Language (DML). DML is use
d for maintaining the data including:
❖ Updating data
❖ Inserting data
❖ Deleting portions of the database
▪ Querying a database
The set of commands used to query the database is c
alled Data Query Language (DQL).
❖ Ordering
❖ Sorting
❖ Retrieving records
DATABASE SYSTEM
❑Report Writer
✓ Simplifies creation of reports
✓ Users typically specify:
❖ What elements they want printed
❖ How the report should be formatted
✓ The report writer then:
❖ Searches the database
❖ Extracts specified data
❖ Prints them out according to specified format
RELATIONAL DATABASES
Relational Data Model
Presents related data in the forms of tables
Relation
RELATIONAL DATABASES
Alternatives for Storing Data
❑ Store all data in one uniform table.
For example, instead of separate tables for students
and classes, we could store all data in one table and
have a separate line for each student x class
combination.
❑Store each student in one row of the table and create
multiple columns to accommodate each class that he is
taking.
First
Student ID Last Name Name Phone No. Course No. Section Day Time
333-33-3333 Simpson Alice 333-3333 ACCT-3603 1 M 9:00 AM
333-33-3333 Simpson Alice 333-3333 FIN-3213 3 Th 11:00 AM
333-33-3333 Simpson Alice 333-3333 MGMT-3021 11 TH 12:00 PM
111-11-1111 Sanders Ned 444-4444 ACCT-3433 2 T 10:00 AM
111-11-1111 Sanders Ned 444-4444 MGMT-3021 5 W 8:00 AM
111-11-1111 Sanders Ned 444-4444 ANSI-1422 7 F 9:00 AM
123-45-6789 Moore Artie 555-5555 ACCT-3433 2 T 10:00 AM
123-45-6789 Moore Artie 555-5555 FIN-3213 3 Th 11:00 AM
• Suppose Alice Simpson changes her phone number. You need to make
the change in three places. If you fail to change it in all three places or
change it incorrectly in one place, then the records for
Alice will be inconsistent.
• This problem is referred to as an update anomaly.
First
Student ID Last Name Name Phone No. Course No. Sect. Day Time
333-33-3333 Simpson Alice 333-3333 ACCT-3603 1 M 9:00 AM
333-33-3333 Simpson Alice 333-3333 FIN-3213 3 Th 11:00 AM
333-33-3333 Simpson Alice 333-3333 MGMT-3021 11 TH 12:00 PM
111-11-1111 Sanders Ned 444-4444 ACCT-3433 2 T 10:00 AM
111-11-1111 Sanders Ned 444-4444 MGMT-3021 5 W 8:00 AM
111-11-1111 Sanders Ned 444-4444 ANSI-1422 7 F 9:00 AM
123-45-6789 Moore Artie 555-5555 ACCT-3433 2 T 10:00 AM
123-45-6789 Moore Artie 555-5555 FIN-3213 3 Th 11:00 AM
• What happens if you have a new student to add, but he hasn’t signed up
for any courses yet?
• Or what if there is a new class to add, but there are no students enrolled
in it yet? In either case, the record will be partially blank.
• This problem is referred to as an insert anomaly.
First
Student ID Last Name Name Phone No. Course No. Sect. Day Time
333-33-3333 Simpson Alice 333-3333 ACCT-3603 1 M 9:00 AM
333-33-3333 Simpson Alice 333-3333 FIN-3213 3 Th 11:00 AM
333-33-3333 Simpson Alice 333-3333 MGMT-3021 11 TH 12:00 PM
111-11-1111 Sanders Ned 444-4444 ACCT-3433 2 T 10:00 AM
111-11-1111 Sanders Ned 444-4444 MGMT-3021 5 W 8:00 AM
111-11-1111 Sanders Ned 444-4444 ANSI-1422 7 F 9:00 AM
123-45-6789 Moore Artie 555-5555 ACCT-3433 2 T 10:00 AM
123-45-6789 Moore Artie 555-5555 FIN-3213 3 Th 11:00 AM
• If Ned withdraws from all his classes and you eliminate all three of
his rows from the table, then you will no longer have a record of Ned. If
Ned is planning to take classes next semester, then you probably didn’t
really want to delete all records of him.
• This problem is referred to as a delete anomaly.
First
Student ID Last Name Name Phone No Class 1 Class 2 Class 3 Class 4
ACCT-36 MGMT-3
333-33-3333 Simpson Alice 333-3333 03 FIN-3213 021
ACCT-34 MGMT-3 ANSI-142
111-11-1111 Sanders Ned 444-4444 33 021 2
ACCT-34
123-45-6789 Moore Artie 555-5555 33 FIN-3213
RELATIONAL DATABASES
ADVISORS
Advisor No. Last Name First Name Office No.
1418 Howard Glen 420
1419 Melton Amy 316
1503 Zhang Xi 202
1506 Radowski J.D. 203
DESIGNING RELATIONAL DATABASE
1. Normalization
✓ Starts with the assumption that everything is initially
stored in one large table.
✓ A set of rules is followed to decompose that initial table
into a set of normalized tables.
✓ Objective is to produce a set of tables in third-normal
form (3NF) because such tables are free of update,
insert, and delete anomalies.
DESIGNING RELATIONAL DATABASE