Supplemental Topic: DATABASES. What is Data? anything you want/need to know –facts –documents...
-
date post
22-Dec-2015 -
Category
Documents
-
view
219 -
download
1
Transcript of Supplemental Topic: DATABASES. What is Data? anything you want/need to know –facts –documents...
Supplemental Topic:
DATABASES
What is Data?
• anything you want/need to know– facts– documents– sounds– images
• Database is an organized collection of related data– easily stored, manipulated, retrieved– common domain of interest
Data vs. Information
• data is cheap, information is useful
Baker, Kenneth D. 324917628Doyle, Joan E. 476193248Finkle, Clive R. 548429344Lewis, John C. 551742186McFerran, Debra R. 409723145Sisneros, Michael 392416582
InformationClass Roster
Course: 615-230 Semester 1, 2002
Database Concepts
Tutorial: 12
Name ID Grade
Baker, Kenneth D. 324917628 HD
Doyle, Joan E. 476193248 HD
Finkle, Clive R. 548429344 HD
Lewis, John C. 551742186 HD
McFerran, Debra R. 409723145 HD
Sisneros, Michael 392416582 HD
Terminology
Database – a collection of inter-related, shared, and controlled data
Database Management System (DBMS) – an application software that allows users to create and operate a database (MS Access, Paradox, Oracle, Sybase, DB2).
Traditional file system – a system where each application has its own set of files (next slide)
Traditional File Management
Customer File
Savings Account File
Customer File
Loan Account File
Customer File
Checking Account File
FilesSavings AccountSystem
Loan AccountSystem
CheckingSystem
Application Programs Users
DBMS facilitates the management of database
Database
Savings AccountSystem
Loan AccountSystemCheckingSystem
Application Programs Users
Customer Table
Savings Account Table
Loan Account Table
Checking Account Table
DatabaseManagement System
DBMS vs. Traditional File Systems
Data redundancy and inconsistency is reduced Information is easier to access and use
DBMS unifies otherwise distinct files by specifying relationships between files
Maintaining data and ensuring security and integrity of data is simpler control is centralized
Physical structure of data and physical access mechanism are independent of application programs changes in physical storage structure and access
mechanism do NOT require changes to application programs
DBMS vs. Traditional File Systems
Three Database Models of DBMS
Hierarchical: Top-down, Tree-like structure Network: (Graph) Record-type connected in
one-one and one-many relationship Relational: Two-dimensional tables related
by common data elements
Three Database Models
Hierarchical Model - data is organized like a tree; only one to many relationships
Dept. A Dept. B
Division 1
Employee 1
Employee 2
Employee 3
Dept. A Dept. B
Division 1
Employee 1
Employee 2
Employee 3
Network Model- data is organized like a graph; one to many and many to many relationships
Three Database Models
Relational Model - data is organized into two-dimensional tables flexible approach to establish relationships
tables linked via a common data element MS-Access is an implementation of the relational
model
Summary: Three DBMS models
Problem Hierarchical Network Relational
Dimension DBMS DBMS DBMS
Data relationship
One-to-many Many-to-many
Flexible
Transaction volume
High Medium Medium, but improving
Flexibility of info. retrieval
Low Low High
Ease of use for end users
Low Low High
Relational Databases
Basic Definitions
• Entity
• Attribute
• Relationship
• Database
• DBMS
• Relational Database
Terminology
entity - a person, place, thing or event
attribute - a characteristic of an entity
products orders customersclassrooms
Examplesname, pricedate, amountname, addressnumber, building, size
Examples
Entity
Just like a noun; a person, place, thing, or event.
Examples
Attribute
Property of an entity (adjective, adverb)
Examples
Relationship
Association between entities
Examples
Database
Structure that can house information about multiple types of entities, the attributes of these entities, and the relationships among the entities.
Examples
Database Management Systems
Software product through which users interact with a database.
Examples
Relational Definitions
• Relation: “A named, two-dimensional table of data.”• Structure notation:
EMPLOYEE1(Emp_ID,Name,Dept_Name,Salary)DEPARTMENT(DEPT_Name,Location,Fax)
… properties
• each row is unique
• each column (attribute) has a unique name (though can be same domain)
• sequence of columns irrelevant
• sequence of rows irrelevant (but can be controlled for output)
Entity:
• A “thing” in the real world with an independent existence
• A person, place, thing, or event
• Physical: such as person and place
• Conceptual: such as job, company, college course
Terminology - The Data Hierarchy
Database
Files (Tables)
Records (Rows)
Fields (Columns)
a group of logically related files or tables
a collection of related records
a group of related fields
a group of characteristics
The Data Hierarchy
Database
Files (Tables)
Records (Rows)
Fields (Columns)
Customer Database
CustomerTable
OrderTable
InvoiceTable
01 John Smith 22 Pinewood Ave Sudbury MA ..02 Karla Stokes 13 Whaley Ave New Haven CT …03 George Vasta 100 Brook St. Killingly CT..
George Vasta (Name Field)
01 George Vasta 100 Brook St. Killingly CT
Keys
primary key - a field which uniquely identifies a record
John Smith 22 Pinewood Ave Sudbury MA .. Karla Stokes 13 Whaley Ave New Haven CT …George Vasta 100 Brook St. Killingly CT..
000010000200003
CustomerId Name Address
foreign key - a field in one table which references a field of another table
9/30/98 $125.67 10/1/98 $ 75.90 10/2/98 $ 82.75
000010000200003
OrderId CustomerId Date Amount000010000200001
Customer Table
Order Table
Two Relational Integrity Rules
Entity Integrity - All records must be uniquely identified (no nulls or duplicates)
Referential Integrity - Foreign key values must match field values in reference table (no dangling references)
Two Relational Integrity Rules
Entity Integrity - All records must be uniquely identified (no nulls or duplicates)
00001 John Smith 22 Pinewood Ave Sudbury MA ..00001 Karla Stokes 13 Whaley Ave New Haven CT … George Vasta 100 Brook St. Killingly CT..
No
CustomerId Name Address
Customer Table
Two Relational Integrity Rules
Referential Integrity - Foreign key values must match field values in reference table (no dangling references)
John Smith 22 Pinewood Ave Sudbury MA ..Karla Stokes 13 Whaley Ave New Haven CT George Vasta 100 Brook St. Killingly CT..
9/30/98 $125.67 10/1/98 $ 75.90 10/2/98 $ 82.75
000010000200003
OrderId CustomerId Date Amount
000010000200005
000010000200003
No
CustomerId Name AddressCustomer Table
Order Table
Schema for four relations (Pine Valley Furniture)
CUSTOMER (Customer_ID,Customer_Name,Address,City,State,Zip)ORDER (Order_ID,Order_Date,Customer_ID)ORDER_LINE (Order_ID,Product_ID,Quantity)PRODUCT (Product_ID,Product_Description,Product_Finish,Unit_Price,On_Hand)
Instance of a relational schema
Relation Normalization
In order for relational structures to be useful and manageable, the relational tables must be “normalized”
The Three Steps of Normalization
Unnormalized Relationship
Normalized Relations(1NF)
Second Normal (2NF) Relations
Third Normal Form (3NF) Relations
Step 1:Remove Repeating Groups
Step 2:Remove Partial Dependencies
Step 3:Remove Transitive Dependencies
One-to-One Relationship
ID Husband_Name
112-09-2293 John Smith
ID Husband_ID Wife_Name
221-90-9322 112-09-2293 Joann Smith
One-to-Many Relationship
Customer_ID Customer_Name
112 ABC Corp
Order_Number Customer_ID Order_Amount
001 112 20
003 112 10
Establishing Many to Many Relationships
DepartmentID
DepartmentName
Department Table
DepartmentID
EmployeeID
Dept_X_EmployeeTable
EmployeeId
Name
Address
Employee Table
1
M
M
1•Need a “Cross” Table
•Specify two one-to-many relationships
Entity Relationship Diagrams
• used to design the database (storage) component
• shows relationships between entities– entity - person, place, thing, event
• symbols
Relationship Entity
Entity Relationship Diagram - Example
Patient
InvoicesPayments
Servicesis provided
are accounted for by
makes
are applied to
1 M
1
M1
MMM
1:M == 1 to many relationshipM:M == many to many relationship
Entity-Relationship ModelExample of schema in the entity-relationship model
A Sample Relational Database
Data Dictionary : Properties(also called meta-data)
Data Elements NAME: Last-Name (Attribute)DEFINITION: Designates patients last
name.TYPE: characterLENGTH: 15ALIASES: Last NameFILE WHERE FOUND: Client, Payment PROCESS 1.0 Capture PaymentWHERE USED: 2.0 Track Payments 3.0 Prepare Bills
A data dictionary is used in solution design to define and describe each piece of data and the data groupings used in information systems.
Database Design Process Step 1
• Information-level design– gather user requirements– design a database that meets requirements as
cleanly as possible– independent of DBMS
Database Design ProcessStep 2
• Concerned with characteristics of specific DBMS
• Must resolve issues such as– column names– data type– number of columns– data length