0% found this document useful (0 votes)
5 views

4. Relational Database

Chapter Four discusses relational databases, emphasizing the differences between files and databases, the importance of database systems, and the advantages they provide such as data integration and minimal redundancy. It explains the structure of databases, including the roles of database management systems (DBMS) and database administrators, as well as the separation of logical and physical views of data. The chapter also covers the significance of schemas, data dictionaries, and the languages used for database creation, manipulation, and querying.

Uploaded by

gizawtade11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

4. Relational Database

Chapter Four discusses relational databases, emphasizing the differences between files and databases, the importance of database systems, and the advantages they provide such as data integration and minimal redundancy. It explains the structure of databases, including the roles of database management systems (DBMS) and database administrators, as well as the separation of logical and physical views of data. The chapter also covers the significance of schemas, data dictionaries, and the languages used for database creation, manipulation, and querying.

Uploaded by

gizawtade11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 64

CHAPTER FOUR:

RELATIONAL DATABASES

CONTENTS:
4.1. FILES VS DATABASES
4.2. IMPORTANCE OF DATABASE SYSTEMS
4.3. DATABASE SYSEMS
4.4. RELATIONAL DATABASES
1
4.1. 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.
– Information about the attributes of an entity
(e.g., the student’s ID number and birth date)
are stored in fields.
– All the fields containing data about one entity
(e.g., one student) form a record.
2
– The example below shows the record for Artie
Moore.
STUDENTS

First Phone
Student ID Last Name Name Number Birth 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

3
– A set of all related records forms a file (e.g.,
the student file).
– If this university only had three students and
five fields for each student, then the entire
file would be depicted below.

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


4
– A set of interrelated, centrally coordinated
files forms a database.

Student Class
File File

Advisor
File

5
• Database systems were developed to
address the problems associated with the
proliferation of master files.
– For years, each time a new information need
arose, companies created new files and
programs.
– The result: a significant increase in the
number of master files.

6
• This proliferation of master
files created problems:
– Often the same information
Master File 1
Fact A
Enrollment
Program
was stored in multiple master
Fact B files.
Fact C – Made it more difficult to
effectively integrate data and
Master File 2
obtain an organization-wide
Fact A Financial Aid view of the data.
Program
Fact D – Also, the same information
Fact F
may not have been consistent
between files.
Master File 1
Grades
• If a student changed his
Fact A Program phone number, it may have
Fact B been updated in one master
Fact F
file but not another. 7
Database • A database is a set of
Fact A Fact B
Fact C Fact D inter-related, centrally
Fact E Fact F coordinated files.

Database
Management
System

Enrollment Financial Aid Grades


Program Program Program

8
• The database approach
treats data as an
organizational resource
Database that should be used by
Fact A Fact B and managed for the
Fact C Fact D
Fact E Fact F
entire organization, not
just a particular
department.
Database
Management
• A database
System management system
(DBMS) serves as the
Enrollment Financial Aid Grades
interface between the
Program Program Program database and the
various application
programs.
9
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 Financial Aid Grades
Program Program Program system.

10
• The person responsible
for the database is the
Database
Fact A Fact B database
Fact C Fact D administrator.
Fact E Fact F
• As technology improves,
Database
many large companies
Management are developing very
System
large databases called
data warehouses.
Enrollment Financial Aid Grades
Program Program Program

11
4.2. IMPORTANCE AND ADVANTAGES OF
DATABASE SYSTEMS
 As accountants, you are likely to audit or work for
companies that use database technology to
store, process, and report accounting
transactions.
– Many accountants work directly with databases and
will enter, process, and query databases.
– Some will develop and evaluate internal controls
necessary to ensure database integrity.
– Others will be involved in the design and
management of databases.
12
Database technology provides the following
benefits to organizations:
• Data integration:- Achieved by combining
master files into larger pools of data accessible
by many programs.
• Data sharing:-It’s easier to share data
• Reporting flexibility:-Reports can be revised easily
and generated as needed. The database can easily be
browsed to research problems or obtain detailed
information.
• Minimal data redundancy and inconsistencies:-
Because data items are usually stored only once.
13
• Data independence:-Data items are independent of the
programs that use them. Consequently, a data item can
be changed without changing the program and vice
versa. Hence, it makes programming easier and
simplifies data management.
• Central management of data:-Data management is
more efficient because the database administrator is
responsible for coordinating, controlling, and managing
data.
• Cross-functional analysis:-Relationships can be explicitly
defined and used in the preparation of management
reports. EXAMPLE: Relationship between selling costs
and promotional campaigns.
14
4.3. DATABASE SYSTEMS
• Logical and physical views of data:
– In file-oriented systems, programmers must
know the physical location and layout of records
used by a program.
• They must reference the location, length, and
format of every field they utilize.
• When data is used from several files, this process
becomes more complex.
– Database systems overcome this problem by
separating the storage and use of data
elements. 15
– Two separate views of the data are
provided:
• Logical view: -How the user or programmer
conceptually organizes and understands the
data.
• Physical view:-How and where the data are
physically arranged and stored.
– Separating these views facilitates
application development, because
programmers can focus on coding the
logic and not be concerned with storage
details. 16
Logical View—User A Logical View—User B
Scholarship Distribution
Enrollment by Class Fr.
5%
Sr. Soph.
33% 24%

Jr.
38%

The DBMS translates


DBMS users’ logical views
into instructions as to
Operating which data should be
System retrieved from the
database.

Database
17
Logical View—User A Logical View—User B
Scholarship Distribution
Enrollment by Class Fr.
5%
Sr. Soph.
33% 24%

Jr.
38%

DBMS
The operating system
Operating translates DBMS
System
requests into
instructions to physically
retrieve data from
Database various disks.
18
• The DBMS handles the link between the physical
and logical views of the data.
– Allows the user to access, query, and update data
without reference to how or where it is physically
stored.
– The user only needs to define the logical data
requirements.
• Separating the logical and physical views of data
also means users can change their
conceptualizations of the data relationships
without making changes in the physical storage.

19
• The database administrator can also change the
physical storage of the data without affecting
users or application programs.
• Schemas-A schema describes the logical
structure of a database. There are three levels of
schema.
(1) Conceptual level:
• The organization-wide view of the entire
database—i.e., the big picture.
• Lists all data elements and the relationships
between them.
20
Subschema--User A Subschema--User B Subschema--User C
Smith . . . A
Jones . . . B
Arnold . . .D

Mapping external-level views to conceptual-level schema

Classes Enroll Student

Cash
Receipt

Mapping conceptual-level items to internal-level descriptions

Student Record Class Record


Student No. --character [9] Class Name --character [9]
Student Name --character [26] Dept No. --integer [4], non-null, index=itemx
SAT Score --integer [2], non-null, index=itemx Course No. --integer [4], non-null, index=itemx
21
(2) External level
• A set of individual user views of portions of
the database, i.e., how each user sees the
portion of the system with which he interacts.
• These individual views are referred to as
subschema.

22
Subschema--User A Subschema--User B Subschema--User C
Smith . . . A
Jones . . . B
Arnold . . .D

Mapping external-level views to conceptual-level schema

Classes Enroll Student

Cash
Receipt

Mapping conceptual-level items to internal-level descriptions

Student Record Class Record


Student No. --character [9] Class Name --character [9]
Student Name --character [26] Dept No. --integer [4], non-null, index=itemx
SAT Score --integer [2], non-null, index=itemx Course No. --integer [4], non-null, index=itemx
23
(3) Internal level:
• A low-level view of the database.
• It describes how the data are actually stored
and accessed including:
– Record layouts
– Definitions
– Addresses
– Indexes

24
Subschema--User A Subschema--User B Subschema--User C
Smith . . . A
Jones . . . B
Arnold . . .D

Mapping external-level views to conceptual-level schema

Classes Enroll Student

Cash
Receipt

Mapping conceptual-level items to internal-level descriptions

Student Record Class Record


Student No. --character [9] Class Name --character [9]
Student Name --character [26] Dept No. --integer [4], non-null, index=itemx
SAT Score --integer [2], non-null, index=itemx Course No. --integer [4], non-null, index=itemx
25
Subschema--User A Subschema--User B Subschema--User C
Smith . . . A
Jones . . . B
Arnold . . .D

Mapping external-level views to conceptual-level schema

The
Classes Enroll Student bidirectional
arrows
represent
mappings
Cash
between the
Receipt
schema.

Mapping conceptual-level items to internal-level descriptions

Student Record Class Record


Student No. --character [9] Class Name --character [9]
Student Name --character [26] Dept No. --integer [4], non-null, index=itemx
SAT Score --integer [2], non-null, index=itemx Course No. --integer [4], non-null, index=itemx
26
• The DBMS uses the mappings to translate a
request by a user or program for data
(expressed in logical names and relationships)
into the indexes and addresses needed to
physically access the data.
• Accountants are frequently involved in
developing conceptual- and external-level
schema.
• An employee’s access to data should be limited
to the subschema of data that is relevant to the
performance of his job.
27
• The data dictionary
– A key component of a DBMS is the data dictionary.
• Contains information about the structure of the database.
• For each data element, there is a corresponding record in
the data dictionary describing that element.
• 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.
28
 Accountants should participate in the development of the data
dictionary because they have a good understanding of the data
elements in a business organization, as well as where those
elements originate and how they are used.
• 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 IS users in:
– Designing and implementing the system.
– Documenting the system.
– Creating an audit trail.
29
• DBMS Languages
– Every DBMS must provide a means of
performing the three basic functions of:
• Creating a database
• Changing a database
• Querying a database

30
• 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

31
• 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

32
• 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.
33
• Report Writer
– Many DBMS packages also include a report
writer, a language that simplifies the 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
34
• Users typically have access to both DQL and report
writer.
• Access to DQL and DML are typically restricted to
employees with administrative and programming
responsibilities.

35
4-4.RELATIONAL DATABASES
• A 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 model developed by
E. F. Codd in 1970.
• The relational data model represents
everything in the database as being stored in
the forms of tables (relations).
36
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Simpson Alice 333-3333
Relation
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 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 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
• This model only describes how the data appear
in the conceptual- and external-level schemas.
• The data are physically stored according to the
description in the internal-level schema.

38
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Simpson Alice 333-3333
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 555-5555

- Each row is called a tuple, which rhymes with


“couple.”
- Each row contains data about a specific
occurrence of the type of entity in the table.
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Simpson Alice 333-3333
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 555-5555

- Each column in a table contains information


about a specific attribute of the entity.
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Simpson Alice 333-3333
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 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

- A primary key is the attribute or combination of


attributes that uniquely identifies a specific row in a table.
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Simpson Alice 333-3333
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 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
In some tables, two or more
333333333-1236 attributes may be joined to form the
111111111-1235 primary key.
111111111-1236
STUDENTS
First Advisor
Student ID Last Name Name Phone No. No.
333-33-3333 Simpson Alice 333-3333 1418
111-11-1111 Sanders Ned 444-4444 1418
123-45-6789 Moore Artie 555-5555 1503

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

A foreign key is an attribute in one table that is a primary


key in another table. They are used to link tables together.
STUDENTS
First Advisor
Student ID Last Name Name Phone No. No.
333-33-3333 Simpson Alice 333-3333 1418
111-11-1111 Sanders Ned 444-4444 1418
123-45-6789 Moore Artie 555-5555 1503

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

Other non-key attributes in each table store important


information about the entity.
• Alternatives for storing data
– One possible alternate approach would be to
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.

45
Last First
Student ID 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

• Using the suggested approach, a student taking three


classes would need three rows in the table.
• In the above, simplified example, a number of problems
arise.
Last First
Student ID 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.
Last First
Student ID 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

• 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.
Last First
Student ID 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

• 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.
• Another possible approach would be to store each
student in one row of the table and create
multiple columns to accommodate each class that
he is taking.

50
Last First Phone
Student ID Name Name No. Class 1 Class 2 Class 3 Class 4

333-33-3333 Simpson Alice 333-3333 ACCT-3603 FIN-3213 MGMT-3021

111-11-1111 Sanders Ned 444-4444 ACCT-3433 MGMT-3021 ANSI-1422

123-45-6789 Moore Artie 555-5555 ACCT-3433 FIN-3213

• This approach is also fraught with problems:


– How many classes should you allow in building the table?
– The above table is quite simplified. In reality, you might need
to allow for 20 or more classes (assuming a student could take
many 1-hour classes).
– Also, more information than just the course number would be
stored for each class. There would be a great deal of wasted
space for all the students taking fewer than the maximum
possible number of classes.
– Also, if you wanted a list of every student taking MGMT-3021,
notice that you would have to search multiple attributes.
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Simpson Alice 333-3333
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 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 • The solution to the preceding problems is
SCID to use a set of tables in a relational
333333333-1234
database.
333333333-1236
• Each entity is stored in a separate table,
111111111-1235
111111111-1236 and separate tables or foreign keys can be
used to link the entities together.
• Basic requirements of a relational database:
(1) Every column in a row must be single valued.
• In other words, every cell can have one and only one
value.
(2) The primary key cannot be null.
• The primary key uniquely identifies a specific row in the
table, so it cannot be null, and it must be unique for every
record.
• This rule is referred to as the entity integrity rule.
(3) 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.
53
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Simpson Alice 333-3333
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 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
• Note that within each table, there are no
SCID
duplicate primary keys and no null
333333333-1234
333333333-1236 primary keys.
111111111-1235 • Consistent with the entity integrity rule.
111111111-1236
(4) All non-key attributes in a table should describe a
characteristic of the object identified by the primary key.
• The preceding four constraints produce a well-structured
(normalized) database in which:
– Data are consistent.
– Redundancy is minimized and controlled.
• In a normalized database, attributes appear multiple
times only when they function as foreign keys.
• The referential integrity rule ensures there will be no
update anomaly problem with foreign keys.

55
STUDENTS
First Advisor
Student ID Last Name Name Phone No. No.
333-33-3333 Simpson Alice 333-3333 1418
111-11-1111 Sanders Ned 444-4444 1418
123-45-6789 Moore Artie 555-5555 1503

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

Advisor No. is a foreign key in the STUDENTS table. Every incident


of Advisor No. in the STUDENTS table either matches an instance
of the primary key in the ADVISORS table or is null.
• An important feature is that data about various things of
interest (entities) are stored in separate tables.
– Makes it easier to add new data to the system.
• You add a new student by adding a row to the student table.
• You add a new course by adding a row to the course table.
• Means you can add a student even if he hasn’t signed up for
any courses.
• And you can add a class even if no students are yet enrolled
in it.
– Makes it easy to avoid the insert anomaly.
• Space is also used more efficiently than in the other
schemes. There should be no blank rows or attributes.

57
STUDENTS
• Add a
Last First Phone student
Student ID Name Name No. here.
333-33-3333 Simpson Alice 333-3333 • Leaves no
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 555-5555 blank spaces.

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 • Add a course here.
333333333-1234 • Leaves no blank spaces.
333333333-1236
111111111-1235 • When a particular student enrolls for
111111111-1236 a particular course, add that info
• Deletion of a class for a student would cause
the elimination of one record in the student x
class table.
– The student still exists in the student table.
– The class still exists in the class table.
– Avoids the delete anomaly.

59
STUDENTS
Last First Phone • Ned still
Student ID Name Name No. exists in the
333-33-3333 Simpson Alice 333-3333 student
111-11-1111 Sanders Ned 444-4444 table.
123-45-6789 Moore Artie 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
• Even if Ned was the only student in the
SCID
class, ACCT-3603 still exists in the course
333333333-1234
table.
333333333-1236
111111111-1235 • If Ned Sanders drops ACCT-3603, remove
111111111-1236 Ned’s class from this table.
• There are two basic ways to design well-
structured relational databases.
– Normalization
– Semantic data modeling

61
• 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.

62
• Semantic data modeling
– Database designer uses knowledge about how business
processes typically work and the information needs
associated with transaction processing to draw a
graphical picture of what should be included in the
database.
– The resulting graphic is used to create a set of
relational tables that are in 3NF.

63
• Advantages over simply following normalization rules:
– Semantic data modeling uses the designer’s
knowledge about business processes and practices; it
therefore facilitates efficient design of transaction
processing databases.
– The resulting graphical model explicitly represents
information about the organization’s business
processes and policies and facilitates communication
with intended users.
• Creating relational database queries
– Databases store data for people and organizations.
– To retrieve the data, you query the database and its
tables by using Microsoft Access in lab class.

*** End of Chapter 4 **** 64

You might also like