Академический Документы
Профессиональный Документы
Культура Документы
ITIS 411
Chapter 1:
Client/Server Databases
and the Oracle 10 g
Relational Database
4 / 90
Textbook
Addresses DB development activities such as:
◦ Using SQL commands to create tables and insert,
update, delete, and view data values.
7 / 90
DB History
The first DBs were stored on large centralized
mainframe computers that users accessed from
terminals
Examples: IMS – Information Management
8 / 90
File-based Systems
Fields (or columns): describe characteristics
about students
◦ Students IDs, last name
9 / 90
File-based Systems
Problems
◦ With managing data stored
in data files.
◦ Proliferation of data
management programs.
◦ Examples: A student
registration system:
12 / 90
Databases and DBMS
A DB stores all organizational data in central
location.
13 / 90
DB Approach to data processing
DBA is the person who is responsible for
installing, administering and maintaining the
DB.
14 / 90
Overview of Relational DBs
Most modern DBs are RDBs.
Stores data in a tabular format.
15 / 90
Overview of Relational DBs
Entity is an object about which you want to
store data (e.g students, faculty, members,
courses, etc)
Storing data about different entities in
16 / 90
Overview of Relational DBs
Relationships among records in different
tables are established through key fields,
values in DB tables that help to either identify
an individual row or to link data from
different tables.
17 / 90
Types of Key Fields: Primary Key
Column in a RDB table whose value must be
unique for each row.
18 / 90
Types of Key Fields: Primary Key
Example
◦ Student ID
◦ Address can’t be a primary key because two
students can have the same address. And the
address can change. And text is prone to errors.
19 / 90
Types of Key Fields: Candidate Key
Any column that could be used as the PK.
20 / 90
Types of Key Fields: Surrogate Key
The below table lacking suitable candidate keys
F_LAST or F-FIRST or even the combination of the two are
not suitable.
A surrogate key is a column that you create to be the
21 / 90
Types of Key Fields: Foreign Key
To create relationships among records.
One way to represent this relationship is to
22 / 90
Types of Key Fields: Foreign Key
The problem with this approach is that it stores
redundant data.
24 / 90
Types of Key Fields: Foreign Key
By using FKs to create relationships, you
repeat only the FK values.
27 / 90
Types of Key Fields: Composite Key
As an alternative to adding a surrogate column for
the PK, a combination of the current columns may
create a value that can uniquely identify each row
in the table. A composite key is a unique key that
you create by combining two or more columns.
Ex: because each student enrolls in each course
only once, the combination of the S_ID column
and the COURSE_NO column represents a unique
identifier of each record.
The combination of the S_ID and GRADE columns
is not unique unless a student could never receive
two As, Bs and so on while completing
coursework at the university.
28 / 90
Types of Key Fields: Composite
Key
The combination of the COURSE _NO and
GRADE columns is not unique, because more
than one student can earn the same grade in
the same class.
30 / 90
DB Design
In the previous examples it is simple to
identify which data elements should be stored
in each table and how each table should be
linked.
In the real world, you may have 1000s of
different data elements for numerous entities,
or you may want to store or track only certain
data.
DB Design
◦ ER models
◦ Normalization
31 / 90
ER Model
Entity-Relationship model is designed to help
identify which entities need to be included in
the DB.
◦ Squares: entities
◦ Lines: relationships between the entities
1-1 Relationships
1-M Relationships
N-M Relationships
32 / 90
1-1 Relationships
Each occurrence of a specific entity (called
instance) is found only once in each set of
data.
◦ Each birth certificate is issued for only one person,
and each person has only one birth certificate.
33 / 90
One to Many (1:M) Relationships
Rare in RDB
An instance can only appear once in one
34 / 90
One to Many (1-M) Relationships
◦ Each of these books would have a FK field that links
back to a specific record in the PUBLISHER table.
Publisher Book
35 / 90
Many to Many (N:M) Relationship
An instance can occur multiple times in each
entity.
◦ A student can take many different classes in the
same term, and each class can be composed of
many different students.
Student Course
It is important to DB designer.
36 / 90
Many to Many (N:M) Relationship
Can’t be represented in the physical DB (i.e.
in the actual DB tables).
If you tried to convert that data set directly
37 / 90
Many to Many (N:M) Relationship
To solve this problem, during the design of
the actual DB tables, the N:M relationship is
broken down into a series of two or more 1:M
relationship through the use of a linking table
in the process of normalization.
38 / 90
Normalization
A step by step process used by DB designers
to determine which data elements should be
stored in which table.
39 / 90
Normalization
JO100 and MA100 are both taking more than
one course.
40 / 90
Normalization
The multiple entries in the COURSE_NO,
COURSE_NAME, CREDITS, and GRADE fields
for these two students are known as
repeating groups.
41 / 90
Normalization
The easiest way to remove repeating groups
is to create a separate record for each value
in the repeating group.
42 / 90
43 / 90
Normalization – 1NF
A primary key field must be identified to convert
the data into first normal form (1NF).
44 / 90
Normalization – 1NF
Notice that no single field can be used to
identify a record.
45 / 90
Normalization – 2NF
Two conditions
◦ It is in 1NF
◦ It has no partial dependencies
46 / 90
Normalization – 2NF
How to identify the partial dependency?
◦ Look at each field that is not part of the composite
PK and make certain you are required to have both
parts of the composite field to determine the value
of the data element and not just one part of the
composite field.
47 / 90
Normalization – 2NF
◦ Example: is the value in the COURSE_NAME field determined by
the combination of values in both the S_ID and COURSE_ID
fields?
50 / 90
Normalization – 2NF
By figuring out which field is determined by
which portion of the composite PK, we have
in fact divided the data into different tables.
◦ Data regarding the student is placed in one table.
◦ Data regarding the course is placed in one table.
◦ Data regarding the student’s grade is placed in one
table.
◦ Each table is given a name
51 / 90
Normalization – 2NF
1NF?
◦ Each table has a PK?
Yes
◦ Each table has no
repeating groups? Yes
2NF?
◦ No partial
dependencies in the
ENROLLMENT table?
Yes
◦ STUDENT & COURSE
tables are already in
2NF because they
don’t have composite
PKs. And they are in
1NF.
52 / 90
Normalization – 3NF
A table is considered to be in 3NF if it is in
2NF and does not have any transitive
dependences.
53 / 90
Normalization – 3NF
1. The ENROLMENT table is in 3NF because the
value in the GRADE field is dependent on:
The primary key
S_ID
COURSE_NO
54 / 90
Normalization – 3NF
3. The STUDENT table
Notice that the advisor’s last name is
dependent on which advisor ID is included
in the student record, not on the student.
STUDENT(S_ID, S_LAST, S_ADDRESS, S_STATE, S_ZIP, F_ID, F_LAST)
COURSE(COURSE_NO, COURSE_NAME, CREDITS)
ENROLLMENT(S_ID + COURSE_NO, GRADE)
55 / 90
Normalization – 3NF
Because the advisors’ last name is not
relevant to the primary keys of the COURSE
and ENROLLMENT tables, it is placed in a
separate table named FACULTY, along with
the F_ID field to uniquely identify each entry
in the new FACUTY table.
FACULTY(F_ID, F_LAST)
STUDENT(S_ID, S_LAST, S_ADDRESS, S_STATE, S_ZIP, F_ID)
Now all fields of STUDENT are entirely
dependent on the primary key S_ID, hence
STUDENT is in 3NF.
56 / 90
Normalization
After converting all tables to 3NF, double
check each table and make sure that all
tables representing entities that have a
relationship are linked through the use of
foreign keys.
57 / 90
Normalization
Student Course
Course
Student
58 / 90
An agency supplies part-time/temporary staff
to hotels within Bahrain. The table shown in
Figure lists the time spent by agency staff
working at various hotels. The CPR INumber
is unique for every member of staff.
Describe and illustrate the process of
59 / 90
60 / 90
DB Systems
DB System consists of:
◦ DBMS: Manages the physical storage and data retrieval
◦ DB applications: provides the interface that allows users
to interact with the DB
66 / 90
Personal vs. Client/Server
On the other hand, a client/server DB is not
affected when a client workstation fails. The
failed client’s in-progress transactions are lost,
but the failure of a single client does not affect
other users.
67 / 90
Personal vs. Client/Server
3- Handle competing user transactions:
In a client/server system the transaction
causes the DB to read the table and
simultaneously lock all or part of the table
prior to updating the table.
69 / 90
Server and Client Processes
Example:
◦ Start an email program
◦ Email program starts a client process
◦ Client process connects to an email server
◦ Email server process
notifies you if you have new messages
sends your new messages when you request them
Forwards your outgoing messages to the recipient’s email
server
72 / 90
Personal DBMS
Access stores all data for a DB in a single
mdb file on a central file server. The client
workstation loads the entire DBMS into main
memory, along with the DB applications to
view, insert, update or print data.
73 / 90
Personal DBMS
74 / 90
Personal DBMS
Personal DB should only be used for
applications that not mission critical.
77 / 90
Personal DBMS
When you perform a transaction in Access,
the personal DB records the related changes
in the client workstation’s main memory in a
record called a transaction log.
78 / 90
Personal DBMS
However, since the transaction log is in the
client workstation’s main memory.
80 / 90
Client/Server DBMS
The DBMS server process runs on one
workstation, while the DB applications run on
separate client workstation.
81 / 90
Client/Server DBMS
Advantages
Generates less network traffic than personal DB.
82 / 90
Client/Server DBMS
In case of transaction processing, they maintain
a file-based transaction log on the DB server.
83 / 90
Client/Server DBMS
They are preferred for DB applications that
retrieve and manipulate small amounts of
data from DB containing large number of
records because
◦ they minimize network traffic
◦ improve response times.
85 / 90
Oracle 10g Client/Server DB
On the server side, the DBA installs and
configures the Oracle 10g DBMS server process.
86 / 90
Oracle 10g Client/Server DB
Client Oracle Net process communicates with
an Oracle Net process running on the DB
server.
87 / 90
Oracle 10g Client/Server DB
Oracle Application Server: used to create
World Wide Web pages that allow users to
access Oracle databases and create dynamic
web pages that interact with an Oracle DB.
88 / 90
Oracle 10g Client/Server DB
Oracle Client products:
◦ SQL*Plus: creating and testing command-line SQL
queries and executing PL/SQL procedural
programs.
PL/SQL is Oracle’s sequential programming language
that is used to create programs that process DB data.
◦ Oracle 10g Developer Suite: develop DB
applications:
Forms Builder: Creating custom user applications
Reports Builder: Creating reports
◦ Enterprise Manager: Performing DB administration
tasks such as creating new user accounts and
configuring how the DBMS stores and manages
data. 89 / 90
Summary:
DB Cases
When creating DB tables:
◦ Convert all tables to 3NF
◦ When linking tables, include the primary key as the
foreign key in the table on the many side of the
relationship
◦ Specify the data type for each column
Use a number data type for columns that store
numerical values that are involved in calculations. i.e.
store phone numbers and postal codes as text strings.
93 / 90
The Clearwater Traders Sales
Order Database
Clothing and sporting goods through mail-
order catalogs
Wants to begin accepting orders using Web
site
Required data consists of information for:
◦ Customers
◦ Orders
◦ Items
◦ Shipments
96 / 90
The Clearwater Traders Sales
Order Database
Tables:
◦ CUSTOMER
◦ ORDER_SOURCE
◦ ORDERS
◦ CATEGORY
◦ ITEM
◦ ORDER_LINE
◦ SHIPMENT
◦ INVENTORY
◦ SHIPMENT_LINE
◦ COLOR
97 / 90
Visual Representation of the
Clearwater Traders Database
98 / 90
The Northwoods University Student
Registration Database
Student registration system
Data items consist of information about:
◦ Students
◦ Courses
◦ Instructors
◦ Student Enrollment
99 / 90
-
The Northwoods University Student
Registration Databas
Tables:
◦ LOCATION
◦ FACULTY
◦ STUDENT
◦ TERM
◦ COURSE
◦ COURSE_SECTION
◦ ENROLLMENT
10 / 90
3
Visual Representation of the
Northwoods University Database
10 / 90
4