AIS CH3 (Relational Database)
AIS CH3 (Relational Database)
1
CHAPTER 3
2
INTRODUCTION
4
FILE VS. DATABASES
• Let’s examine some basic principles about how data are
stored in computer systems.
– An entity is anything about which the organization
wishes to store data. At your college or university,
one entity would be the student.
STUDENTS
Phone
Student ID Last Name First Name Number Birth Date
Phone
Student ID Last Name First Name Number Birth Date
STUDENTS
Phone
Student ID Last Name First Name Number Birth Date
STUDENTS
Phone
Student ID Last Name First Name Number Birth Date
333-33-3333 Samson Seleshe 333-3333 10/11/84
111-11-1111 Abebe Chine 444-4444 11/24/86
123-45-6789 Fugge Ferera 555-5555 04/20/85
8
FILE VS. DATABASES
Student Class
File File
Advisor
File
9
FILE VS. DATABASES
• Database systems were developed to address the
problems associated with the proliferation of
master files.
– For years, each time when a new information
need arose, companies created new files and
programs.
– The result: a significant increase in the number
of master files.
10
FILE VS. DATABASES
• This proliferation of master files
created problems:
Master File 1 Enrollment – Often the same information
Fact A
Fact B
Program was stored in multiple master
Fact C files.
– Made it more difficult to
effectively integrate data and
Master File 2
Fin. Aid
obtain an organization-wide
Fact A
Fact D Program view of the data.
Fact F – Also, the same information
may not have been consistent
between files.
Master File 3
Fact A
Grades e.g. If a student changed his
Program
Fact B phone number, it may have
Fact F been updated in one master
file but not another.
11
FILE VS. DATABASES
Database • Database systems
Fact A Fact B
Fact C Fact D were developed to
Fact E Fact F address the above
stated problems
Database
Management
System
12
FILE VS. DATABASES
• The database approach treats
Database
Fact A Fact B data as an organizational
Fact C Fact D resource that should be used
Fact E Fact F by entire organization and
managed for the entire
organization,
Database
Management • Data is not just a particular
System department.
• A database management
system (DBMS) serves as
Enrollment
Program
Fin. Aid
Program
Grades
Program
the interface between the
database and the various
application programs.
13
FILE VS. DATABASES
Database • The combination of
Fact A Fact B
Fact C Fact D the database, the
Fact E Fact F DBMS, and the
application programs
Database
Management
that access the
System database is referred
to as the database
Enrollment
Program
Fin. Aid
Program
Grades
Program
system.
14
FILE VS. DATABASES
Database • The person responsible
Fact A Fact B for the database is the
Fact C Fact D
Fact E Fact F database
administrator.
Database • As technology
Management
System
improves, many large
companies are
Enrollment Fin. Aid Grades
developing very large
Program Program Program databases called data
warehouses.
15
IMPORTANCE AND ADVANTAGES OF DATABASE SYSTEMS
17
IMPORTANCE AND ADVANTAGES OF DATABASE SYSTEMS
18
IMPORTANCE AND ADVANTAGES OF DATABASE SYSTEMS
21
IMPORTANCE AND ADVANTAGES OF DATABASE SYSTEMS
24
DATABASE SYSTEMS
• Database systems overcome this problem by
separating the storage and use of data
elements.
Two separate views of the data are provided:
• Logical view
How the user or programmer
conceptually organizes and
understands the data.
25
DATABASE SYSTEMS
• Database systems overcome this problem by
separating the storage and use of data elements.
– Two separate views of the data are provided:
• Logical view
• Physical view
Jr.
38%
Jr.
38%
03/21/2022
DATABASE SYSTEMS
33
DATABASE SYSTEMS
Information provided for each element includes:
A description or explanation of the element.
The records in which it is contained.
Its source.
The length and type of the field in which it is
stored.
The programs in which it is used.
The outputs in which it is contained.
The authorized users of the element.
Other names for the element. 34
DATABASE SYSTEMS
The DBMS usually maintains the data
dictionary.
– It is often one of the first applications of a
newly implemented database system.
– Inputs to the dictionary include:
• Records of new or deleted data
elements.
• Changes in names, descriptions, or uses
of existing elements.
– Outputs include:
• Reports that are useful to programmers,
database designers, and AIS users. 35
DATABASE SYSTEMS
• DBMS Languages
– Every DBMS must provide a means of
performing the three basic functions of:
• Creating a database
• Changing a database
• Querying a database
36
DATABASE SYSTEMS
• DBMS Languages
– Every DBMS must provide a means of
performing the three basic functions of:
• Creating a database
• Changing a database
• Querying a database
37
DATABASE SYSTEMS
• Creating a database:
– The set of commands used to create the
database is known as data definition language
(DDL). DDL is used to:
• Build the data dictionary
• Initialize or create the database
• Describe the logical views for each
individual user or programmer
• Specify any limitations or constraints on
security imposed on database records or
fields 38
DATABASE SYSTEMS
• DBMS Languages
– Every DBMS must provide a means of
performing the three basic functions of:
• Creating a database
• Changing a database
• Querying a database
39
DATABASE SYSTEMS
• Changing a database
– The set of commands used to change the
database is known as data manipulation
language (DML). DML is used for
maintaining the data including:
• Updating data
• Inserting data
• Deleting portions of the database
40
DATABASE SYSTEMS
• DBMS Languages
– Every DBMS must provide a means of
performing the three basic functions of:
• Creating a database
• Changing a database
• Querying a database
41
DATABASE SYSTEMS
• Querying a database:
– The set of commands used to query the database is
known as data query language (DQL). DQL is used
to interrogate the database, including:
• Retrieving records
• Sorting records
• Ordering records
• Presenting subsets of the database
– The DQL usually contains easy-to-use, powerful
commands that enable users to satisfy their own
information needs.
42
RELATIONAL DATABASES
• DBMS is characterized by the type of
logical data model on which it is based.
– A data model is an abstract representation
of the contents of a database.
– Most new DBMSs are called relational
databases because they use the relational
data model developed by E.F. Codd in
1970.
43
RELATIONAL DATABASES
• The relational data model represents
everything in the database as being stored
in the forms of tables (aka, relations).
44
STUDENTS
Last First
Student ID Name Name
333-33-3333 Samson Alemu
Relation
111-11-1111 Senait Negadras
123-45-6789 Meron Aseged
COURSES
Course ID Course Section Day Time
1234 ACCT-3603 1 MWF 8:30
1235 ACCT-3603 2 TR 9:30
1236 MGMT-2103 1 MW 8:30
STUDENT x COURSE
SCID Student ID Course
333333333-1234 333-33-3333 1234
333333333-1236 333-33-3333 1236
111111111-1235 111-11-1111 1235
111111111-1236 111-11-1111 1235
RELATIONAL DATABASES
46
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Samson Alemu 333-3333
111-11-1111 Asenafi Negadras 444-4444
123-45-6789 Tilahun Aseged 555-5555
COURSES
Course ID Course Section Day Time
1234 ACCT-3603 1 MWF 8:30
1235 ACCT-3603 2 TR 9:30
1236 MGMT-2103 1 MW 8:30
STUDENT x COURSE
SCID
333333333-1234
333333333-1236
111111111-1235
111111111-1236
Each row contains
STUDENTS
Last First Phone
data about a
Student ID Name Name No. specific
333-33-3333 Samson Alemu 333-3333 occurrence of the
111-11-1111 Asenafi Negadras 444-4444 type of entity in
123-45-6789 Tilahun Aseged 555-5555 the table.
COURSES
Course ID Course Section Day Time
1234 ACCT-3603 1 MWF 8:30
1235 ACCT-3603 2 TR 9:30
1236 MGMT-2103 1 MW 8:30
STUDENT x COURSE
SCID
333333333-1234
333333333-1236
111111111-1235
111111111-1236
Each column in
STUDENTS
Last First Phone
a table contains
Student ID Name Name No. information
333-33-3333 Samson Alemu 333-3333 about a specific
111-11-1111 Asenafi Negadras 444-4444 attribute of the
123-45-6789 Tilahun Aseged 555-5555 entity.
COURSES
Course ID Course Section Day Time
1234 ACCT-3603 1 MWF 8:30
1235 ACCT-3603 2 TR 9:30
1236 MGMT-2103 1 MW 8:30
STUDENT x COURSE
SCID
333333333-1234
333333333-1236
111111111-1235
111111111-1236
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Samson Alemu 333-3333
111-11-1111 Asenafi Negadras 444-4444
123-45-6789 Tilahun Aseged 555-5555
COURSES
Course ID Course Section Day Time
1234 ACCT-3603 1 MWF 8:30
1235 ACCT-3603 2 TR 9:30
1236 MGMT-2103 1 MW 8:30
STUDENT x COURSE
SCID
A primary key is the
333333333-1234 attribute or combination of
333333333-1236 attributes that uniquely
111111111-1235
identifies a specific row in a
111111111-1236
table.
STUDENTS
Last First
Student ID Name Name
333-33-3333 Samson Alemu
111-11-1111 Asenafi Negadras
123-45-6789 Tilahun Aseged
COURSES
Course ID Course Section Day Time
1234 ACCT-3603 1 MWF 8:30
1235 ACCT-3603 2 TR 9:30
1236 MGMT-2103 1 MW 8:30
STUDENT x COURSE
SCID
333333333-1234 In some tables, two or more
333333333-1236 attributes may be joined to form
111111111-1235 the primary key.
111111111-1236
STUDENTS
First Advisor
Student ID Last Name Name Phone No. No.
333-33-3333 Samson Alemu 333-3333 1418
111-11-1111 Asenafi Negadras 444-4444 1418
123-45-6789 Tilahun Aseged 555-5555 1503
ADVISORS
Advisor No. Last Name First Name Office No.
1418 Howard Glen 420
1419 Mengesha Almawu 316
1503 Zenebe Zinabu 202
1506 Robel Jigsaw 203
ADVISORS
Advisor No. Last Name First Name Office No.
1418 Howard Glen 420
1419 Mengesha Almawu 316
1503 Zenebe Zinabu 202
1506 Robel Jigsaw 203
ADVISORS
Advisor No. Last Name First Name Office No.
1418 Howard Glen 420
1419 Mengesha Almawu 316
1503 Zenebe Zinabu 202
1506 Robel Jigsaw 203
COURSES
Course ID Course Section Day Time
1234 ACCT-3603 1 MWF 8:30
1235 ACCT-3603 2 TR 9:30
1236 MGMT-2103 1 MW 8:30
STUDENT x COURSE
SCID • Note that within each table, there are no
333333333-1234 duplicate primary keys and no null
333333333-1236 primary keys.
111111111-1235
• Consistent with the entity integrity rule.
111111111-1236
RELATIONAL DATABASES
• Basic Requirements of a Relational Database
C. A foreign key must either be null or
correspond to the value of a primary key in
another table.
• This rule is referred to as the referential
integrity rule.
• The rule is necessary because foreign keys
are used to link rows in one table to rows in
another table.
57
STUDENTS
First Advisor
Student ID Last Name Name Phone No. No.
333-33-3333 Samson Alemu 333-3333 1418
111-11-1111 Ashenafi Negadras 444-4444 1418
123-45-6789 Tilahun Aseged 555-5555 1503
ADVISORS
Advisor No. Last Name First Name Office No.
1418 Howard Glen 420
1419 Mengesha Almawu 316
1503 Zenebe Zinabu 202
1506 Robel Jigsaw 203
61