Академический Документы
Профессиональный Документы
Культура Документы
4 / 90
Addresses DB development activities such as:
◦ Using SQL commands to create tables and insert,
update, delete, and view data values.
7 / 90
Fields (or columns): describe characteristics
about students
◦ Students IDs, last name
8 / 90
Problems
◦ With managing data stored
in data files.
◦ Proliferation of data
management programs.
◦ Examples: A student
registration system:
11 / 90
12 / 90
A DB stores all organizational data in central
location.
13 / 90
DBA is the person who is responsible for
installing, administering and maintaining the
DB.
14 / 90
Most modern DBs are RDBs.
Stores data in a tabular format.
15 / 90
Entity is an object about which you want to
store data (e.g students, faculty, members,
courses, etc)
Storing data about different entities in
different tables minimizes storing redundant
data.
To connect information about different
entities you must create relationships, which
are links that show how different records are
related.
16 / 90
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
Column in a RDB table whose value must be
unique for each row.
18 / 90
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
Any column that could be used as the PK.
20 / 90
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
record’s PK identifier. It has no real relationship to the
row to which it is assigned, other than to identify the
row uniquely. In Oracle 10g Sequences can be used to
generate unique values for each record. They are
always numerical. Oracle 10g can also generate
numbers with specific increment.
21 / 90
To create relationships among records.
One way to represent this relationship is to
combine the FACULTY and STUDENT fields
into a single table, and store the data for
each student’s faculty advisor directly in each
student row.
22 / 90
The problem with this approach is that it
stores redundant data.
23 / 90
24 / 90
By using FKs to create relationships, you
repeat only the FK values.
31 / 90
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
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
Rare in RDB
An instance can only appear once in one
entity, but one or more times in the other
entity.
◦ A publisher may publish several different books,
but each book is published by only one publisher.
◦ Each publisher would be listed in a PUBLISHER table
only once, but each publisher could have several
books listed in the BOOK table.
34 / 90
◦ Each of these books would have a FK field that links
back to a specific record in the PUBLISHER table.
Publisher Book
35 / 90
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
Can’t be represented in the physical DB (i.e.
in the actual DB tables).
If you tried to convert that data set directly
into two DB tables, one table being the
STUDENT table and the other being the
COURSE table, there would be no way to
correctly link the data in the tables together.
i.e Nearly impossible to correctly retrieve data
from the DB.
37 / 90
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
A step by step process used by DB designers
to determine which data elements should be
stored in which table.
39 / 90
JO100 and MA100 are both taking more than
one course.
40 / 90
The multiple entries in the COURSE_NO,
COURSE_NAME, CREDITS, and GRADE fields
for these two students are known as
repeating groups.
41 / 90
The easiest way to remove repeating groups
is to create a separate record for each value
in the repeating group.
42 / 90
43 / 90
A primary key field must be identified to
convert the data into first normal form (1NF).
44 / 90
Notice that no single field can be used to
identify a record.
45 / 90
Two conditions
◦ It is in 1NF
◦ It has no partial dependencies
46 / 90
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
◦ 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
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
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
A table is considered to be in 3NF if it is in
2NF and does not have any transitive
dependences.
53 / 90
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
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
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)
57 / 90
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
normalizing the table to 3NF.
State any assumptions you make about the
data shown in this table.
59 / 90
60 / 90
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
61 / 90
Personal DB systems, such as Microsoft
Access and FoxPro, are aimed toward
single-user DB applications that usually
are stored on a single user’s desktop
computer, or a client workstation.
64 / 90
Multi-user client/server DBs generate less
network traffic than personal DB.
65 / 90
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.
66 / 90
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.
68 / 90
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
71 / 90
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.
72 / 90
73 / 90
Personal DB should only be used for
applications that not mission critical.
76 / 90
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.
77 / 90
However, since the transaction log is in the
client workstation’s main memory.
79 / 90
The DBMS server process runs on one
workstation, while the DB applications run on
separate client workstation.
80 / 90
Generates less network traffic than personal DB.
81 / 90
In case of transaction processing, they
maintain a file-based transaction log on the
DB server.
82 / 90
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.
84 / 90
On the server side, the DBA installs and
configures the Oracle 10g DBMS server process.
85 / 90
Client Oracle Net process communicates with
an Oracle Net process running on the DB
server.
86 / 90
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.
87 / 90
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.
88 / 90
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.
89 / 90
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
90 / 90
Tables:
◦ CUSTOMER
◦ ORDER_SOURCE
◦ ORDERS
◦ CATEGORY
◦ ITEM
◦ ORDER_LINE
◦ SHIPMENT
◦ INVENTORY
◦ SHIPMENT_LINE
◦ COLOR
91 / 90
92 / 90
Student registration system
Data items consist of information about:
◦ Students
◦ Courses
◦ Instructors
◦ Student Enrollment
93 / 90
Tables:
◦ LOCATION
◦ FACULTY
◦ STUDENT
◦ TERM
◦ COURSE
◦ COURSE_SECTION
◦ ENROLLMENT
94 / 90
95 / 90