Documente Academic
Documente Profesional
Documente Cultură
Questions References
© Lord's Kitchen
Module Outline
Module Flow:
1. 2. 3. 4.
What is a Types of Creating a Structured
Database Database Database Query
System Systems Environment Language
5. 6.
Internal Database
Management Trends
© Lord's Kitchen
1.0 Database System
Learning Objective:
At the end of this Topic you will be able to –
•Understand what is a Database System
•Know how files are organized
•Appreciate the advantages of using a DBMS
over a traditional file system
•Be aware of the Database Architecture
© Lord's Kitchen
File Organization : Terms and Concepts
© Lord's Kitchen
File Organization : Terms and Concepts
Data redundancy
Program-Data dependence
Lack of flexibility
Poor security
© Lord's Kitchen
DBMS and its Advantages
v A Database Management System is a collection of programs that
enables users to create and maintain a database. It is a
general purpose software system that facilitates processes of
defining, constructing and manipulating databases for various
applications.
•
v Advantages of Database approach:
• Controlling Redundancy
• Restricting Unauthorized access
• Providing persistent storage for program objects and data structures
• Permitting inference and actions using deduction rules
• Providing multiple user interface
• Representing complex relationships among data
• Enforcing integrity constraints
• Providing backup and recovery
© Lord's Kitchen
Database Management System (DBMS)
© Lord's Kitchen
DBMS Architecture
© Lord's Kitchen
DBMS Architecture
Data Independence
§ Logical data independence : capacity to
change conceptual schema without
having to change external schema.
§ Physical data independence : capacity to
change internal schema without changing
conceptual schema.
© Lord's Kitchen
Functions of DBMS
Data definition :
• Specifies content and structure of database and defines each data
element
Data manipulation :
• Manipulates data in a database
Data security and integrity :
• Monitors user requests and rejects any unauthorized attempts
Data recovery and concurrency :
• Enforces certain controls for recovery and concurrency
Data dictionary:
• Stores definitions of data elements, and data characteristics
Performance :
• Functions should be performed efficiently
© Lord's Kitchen
Requirements of a DBMS
SELECT JOIN
PROJECT
Outdated
Complex pointer based organization
Less flexible compared to RDBMS
Lack support for ad-hoc and English language-like queries
DEPARTMENT has
EMPLOYEE
works
•Dept No. •Name
for
•Name •Emp Id.
Relations Attribute
Identifie s
hip
r
Examples: EMPLOYEES, PROJECTS, INVOICES
Entity Rules
• Any thing or object may only be represented by one entity. Entities are
mutually exclusive in all cases.
• Each entity must be uniquely identifiable. Each instance (occurrence) of
an entity must be separate and distinctly identifiable from all other
instances of that type of entity.
Entity Classification and Types
• Classified as dependent and independent
• An independent entity is one that does not rely on another for
identification
• A dependent entity is one that relies on another for identification
• In some, methodologies, the terms used are strong and weak,
respectively
has for a
ORDER ORDER LINE ITEM
appears on
belongs to
overlapping (inclusive)
multiple subtypes
Example: Entity PERSON represents people at a university. It has three subtypes,
FACULTY, STAFF, and STUDENT. A STAFF member could also be registered as a
STUDENT
PERSON
Example: Entity EMPLOYEE, may have two subtypes,
CLASSIFIED and WAGES. An employee may be one type
or the other but not both
PERSON
STUDENT FACULTY
UNDERGRAD GRADUATE
Multi-valued Mat
Mod h
Single-
valued ule
Id Student Phy
sics
•
•
•
14/01/2009© Lord's Kitchen 47
E-R Modeling
•Connectivity and Cardinality
•A one-to-one (1:1) relationship is when at most one instance of a entity A
Is associated with one instance of entity B.
For example:
Employees in the company are each assigned their own office. For each
Employee there exists a unique office and for each office there exists a
unique employee.
•A one-to-many (1:N) relationships is when for one instance of entity A,
there are zero, one, or many instances of entity B, but for one instance
of entity B, there is only one instance of entity A.
An example :
A department has many employees each employee is assigned to one department
Department
E-R Modeling - Assignment
How to create an E-R Model from Requirements ?
Step 1: Identify Entities
• Entities are things people talk about, record information about
and do work on – by definition
• Any keyword (noun) is a candidate
• Identify generic object from reference to instances or
occurrences
• Combine synonyms to represent a single entity
An Example : Purchase Order - System Requirements
A buyer creates a purchase order (PO) as and when the need arises. A PO is for a
Specific vendor. A PO has one or more line items. A buyer cannot create a PO of
Total value more than his approval limit. A PO can be sent to the vendor by mail,
fax, EDI. A PO can be canceled before it is submitted. A PO can be linked to a
sales order…
14/01/2009© Lord's Kitchen 55
E-R Modeling
Step 1: Identify Entities
Entities
Purchase Order (PO)
Buyer?
Vendor
Line Items
Sales Order
Approval Limit?
Buyer characterizes a PO
Approval Limit characterizes a Buyer
What does it tell us?
PO
PO replaced by Buyer
belongs to VENDOR
exists on
ITEM LINE
created for
A B C D E
1 A 212 Y 2
2 C 45 N 84
3 B 8656 N 4
4 D 324 N 56
5 C 5656 Y 34
6 A 445 N 4
7 B 546 Y 55
A B C D E
1 A 212 Y 2
2 C 45 N 84
3 B 8656 N 4
4 D 324 N 56
5 C 5656 Y 34
6 A 445 N 4
7 B 546 Y 55
ak ax ay bk bx by
k x y
1 A 2 1 A 2
Table A 1 A 2
1 A 2 4 D 8
2 B 4 1 A 2 5 E 10
3 C 6 2 B 4 1 A 2
A TIMES B
2 B 4 4 D 8
k x y 2 B 4 5 E 10
1 A 2 3 C 6 1 A 2
Table B
4 D 8 3 C 6 4 D 8
5 E 10 3 C 6 5 E 10
14/01/2009© Lord's Kitchen 76
Relational Model
•Join
•Combines the product, selection and projection operations
•Combines (concatenates) data from one row of a table with rows from
another or same table
•Criteria involve a relationship among the columns in the join relational table
•
If the join criterion is based on equality of column value, the result is called an equi join
A natural join is an equi join with redundant columns removed
Joins can also be done on criteria other than equality. Such joins are called non-equi joins
k a b k a b k c
1 A 2 Table B Equi-Join 1 A 2 1 aa
2 B 4 3 C 6 3 bb
3 C 6 k c
1 aa
k a b c
3 bb 1 A 2 aa
Table A 5 cc Natural Join 3 C 6 bb
14/01/2009© Lord's Kitchen 77
Relational Model
•Union
•The UNION operation of two tables is formed by appending rows from
one table to those of a second to produce a third. Duplicate rows are
eliminated
•Tables in an UNION operation must have the same number of columns
and corresponding columns must come from the same domain
A Union B
k x y k x y
1 A 2
1 A 2
2 B 4
3 C 6 Table B 2 B 4
3 C 6
k x y
Table A
1 A 2 4 D 8
4 D 8
5 E 10 5 E 10
A Union B
k x y k x y
1 A 2
1 A 2
2 B 4
3 C 6 Table B 2 B 4
3 C 6
k x y
Table A
1 A 2 4 D 8
4 D 8
5 E 10 5 E 10
A Intersect B
k x y k x y
1 A 2 1 A 2
2 B 4 Table A 4 D 8
3 C 6
5 E 10
k x y
1 A 2 Table B
k x y
1 A 2 A MINUS B k x y
2 B 4 Table A 2 B 4
3 C 6
3 C 6
k x y
1 A 2 k x y
B MINUS A
4 D 8 Table B 4 D 8
5 E 10 5 E 10
14/01/2009© Lord's Kitchen 81
Relational Model
• Division
• The division operator results in columns values in one table for
which there are other matching column values corresponding to every
row in another table.
k x y k
1 A 2 1
1 B 4 3
2 A 2 x y
3 B 4 A 2
4 B 4 A DIV B
B 4
3 A 2
Table A Table B
Full functional dependence applies to tables with composite keys. Column Y in relational
table R is fully functional on X of R where X is a composite key if it is functionally
dependent on X and not functionally dependent upon any subset of X.
3 NF
Remove remaining
Anomalies resulting
from FD‘s
Boyce/Codd NF
Remove multivalued
dependencies
14/01/2009© Lord's Kitchen 84
Normalization
An Example : A company obtains parts from a number of suppliers. Each
supplier is located in one city. A city can have more than one supplier located
there and each city has a status code associated with it. Each supplier may
provide many parts.
A relational table is said to be in the first normal form if all values of the columns
are atomic. That is, they contain no repeating values.
FIRST is in 1NF but not in 2NF because status and city are functionally
dependent upon only on the column s# of the composite key (s#, p#).
A relational table is in third normal form (3NF) if it is already in 2NF and every
non-key column is non transitively dependent upon its primary key.
SUPPLIER
s# city status The table supplier is in 2NF but not in
3NF because it contains a transitive
s1 London 20
dependency
s2 Paris 10 SUPPLIER.s# —> SUPPLIER.city
s3 Tokyo 30 SUPPLIER.city —> SUPPLIER.status
s4 Paris 10 SUPPLIER.s# —> SUPPLIER.status
14/01/2009© Lord's Kitchen 91
Normalization
•Steps for transforming a table into 3NF is:
1.Identify any determinants, other the primary key, and the columns they
determine.
2.Create and name a new table for each determinant and the unique
columns it determines.
3.Move the determined columns from the original table to the new table. The
determinant becomes the primary key of the new table.
CITY_STATUS
SUPPLIER s# city
s1 London city status
s2 Paris London 20
The transformation of s3 Tokyo Paris 10
SUPPLIER into 3NF s4 Paris Tokyo 30
s5 London
Rome 50
s# city CITY_STATUS
s1 London city status
s2 Paris London 20
The transformation of s3 Tokyo Paris 10
SUPPLIER into 3NF s4 Paris Tokyo 30
s5 London
Rome 50
SUPPLIER
14/01/2009© Lord's Kitchen 93
Normalization
• Advanced Forms :: BOYCE CODD NORMAL FORM
Many practitioners argue that placing entities in 3NF is generally
sufficient because it is rare that entities that are in 3NF are not also in
4NF and 5NF. The advanced forms of normalization are:
Ø
Develop an E-R
model and database
schema for a system
to handle purchase
orders.
SELECT column-list
FROM table-names
WHERE condition(s)
Conditional
Selection
1. Projection
WHERE condition(s)
2. Join
3. Selection
Department
SQL will compare every row of the
Dept Code Dept name Office#
1st table with the first row of the 2nd MKT Marketing 244
table. Then it will compare all rows of CIS Comp. Info. Sys. 302
the 1st with the second row of the second, ECO Economics 244
RESULT TABLE
Course_No Course_Title C_Hrs Dept_Code Dept_Name Office#
CIS 120 Intro to CIS 4 Cis Comp. Info S 302
RESULT TABLE
Course_No Course_Title C_Hrs Dept_Code Dept_Name Office#
CIS 120 Intro to CIS 4 Cis Comp. Info S 302
Logical Physical
Page Req. Disk Manager
Page Access
D a t a b a s e s
c e n t r a l d i s i se t d r i b d u a n t t e ea d t b w a d o s a r e kt a s
© Lord's Kitchen
Centralized database
Used by single central processor or multiple processors in
client/server network
System bus
Memory Controller
Memory
Data mart
•Subset of data warehouse
•Contains summarized or highly focused portion of data
for a specified function or group of users
Data mining
•Tools for analyzing large pools of data
•Find hidden patterns and infer rules to predict trends
•
Hypermedia database
• Organizes data as network of nodes
• Links nodes in pattern specified by user
• Supports text, graphic, sound, video and executable
programs
•
Database
Fundamentals