Database

Transcription

Database
Chapter Objectives
Lecture 1
•
•
•
•
•
•
•
Database Management Systems
Spring - 1415
Introduction
Definition of Terms
Database and DBMS
Computerised File Processing
Advantages of Databases
Components of Database Environment
Evolution of Data Models
Achitecture of DB Systems and Data
Independence
2
Spring-1415
Use of Databases
Definition
• Used in large and small organizations.
• Examples
• Data: Raw facts..
– stored representations of meaningful objects and
events
– usually formatted in a special way
– Consumer websites - ordering products
– Online banking, credit card companies
– Supermarkets and retail stores, including inventory
control systems
– Airline reservations, Travel agencies
– Medical records and billing
– Employment records
– Studying at university
– ... etc
Spring-1415
• represented by numbers, characters, pictures, symbols
3
Spring-1415
4
1
Data versus Information
Metadata
• Information
• Data that describe data (properties or characteristics )
– data that have been structured
and processed in such a way to
increase the knowledge of the
person that uses the data
– They describe
• how, when and by whom a particular set of data was collected,
• how the data are formatted.
– data types, field sizes, allowable values, and documentation
– Data dictionary, system catalog
• Metadata are essential for understanding information
– place in a context
– summarised & in report form
- number of students enrolled in each
subject
- number of students summary with
totals & comparisons with previous
quarter/year
Spring-1415
5
Spring-1415
Key points
6
Database
•
•
•
•
Data constitute the building blocks of information.
Information is produced by processing data.
Information is used to reveal the meaning of data.
Accurate, relevant, and timely information is the key to
good decision making.
• Good decision making is the key to organizational survival
• Data Management is a discipline
– proper generation, storage, and retrieval of data.
– a core activity for any business or service organization etc...
• a large, integrated collection of data (end user
data) and metadata
• an integrated collection of logically related data
(and metadata), organized to meet the needs of
multiple users in an organization.
• Efficient data management typically requires the use of a
computer database.
Spring-1415
7
Spring-1415
8
2
Computerized File-Based Systems
Tuition
payment
entry and
reports
Disadvantages of File-Based Systems
• Program-Data (Structural) Dependence
File
handling
routines
SID, name, address,
amountPaid, balance, …
File
definition
Tuition payment application programs
– All programs maintain metadata for each file they use
• Data Redundancy (Duplication of data)
Payment files
File
Course
handling
Registration routines
entry and
File
reports
definition
– Different programs have separate copies of the same data
– Data inconsistency
SID, name, address,
courses, …
• Limited Data Sharing
– No centralized control of data
Course registration application programs Registration files
Recreation
center data
entry and
reports
File
handling
routines
• Lengthy Development Times
SID, name, address, …
– Programmers must design their own file formats
File
definition
Recreation center application programs
• Excessive Program Maintenance
Recreation center files
– 80% of information systems budget
9
Spring-1415
10
Spring-1415
Solution:
File-Based Processing
The DATABASE Approach
• Eliminates many of the problems associated with
File-based system
– Central repository of shared data
– Stored in a standardized, convenient form
– Data is managed by a controlling agent
Requires a Database Management System (DBMS)
Spring-1415
11
Spring-1415
12
3
Database Approach
Database Contents
Course
Registration
entry and
reports
Course registration application programs
Tuition
payment
entry and
reports
Tuition payment application programs
DBMS
Database
Recreation
center data
entry and
reports
Recreation center application programs
Spring-1415
13
14
Spring-1415
DBMS Functions...
Database Management System(DBMS)
• A software system (collection of programs) that
manages the database structure and enables
users to define, create, maintain, and control
access to the data stored in the database
• DBMS Vendors
–
–
–
–
–
–
–
–
Oracle,
Sybase (SAP)
Informix & DB2 (IBM)
Access & SQL Server (Microsoft)
MySQL (Oracle)
PostgreSQL (EnterpriseDB Corp.)
SQLBase (Gupta Technologies)
Ingres (Actian Corp.)
Spring-1415
15
Spring-1415
16
4
Database Management System(DBMS)
Advantages of Database Approach
• Program-Data Independence
– Metadata stored in DBMS, so applications don’t need to
worry about data formats
• Minimal Data Redundancy
– Leads to increased data integrity/consistency
• Improved Data Sharing
– Different users get different views of the data
– Enforcement of Standards
• Improved Data Quality
– Constraints, data validation rules
Spring-1415
17
Advantages of Database Approach
Spring-1415
18
Costs and Risks of the Database Approach
• Up-front Costs:
• Easier & Better Data Accessibility/
Responsiveness
– Installation Cost and Complexity
• Sophisticated Hardware & Software & Personnel
– Use of standard data query language (SQL)
– Conversion Costs
• Multiuser Acess Control Concurrency
• Ongoing Costs
– Uses sophisticated algorithms
–
–
–
–
• Security
– Restricts unauthorized access to data
• Backup/Recovery
Requires New/Highly Skilled /Specialized Personnel
Keep the System Current
Vendor Dependence,
Frequent Upgrade Cyccles
– Critical to preserving the database’s integrity
Spring-1415
19
Spring-1415
20
5
Database Environment
People
• System Analyst & Application Programmer
– responsible for designing and implementing the application programs in a
conventional programming language (PL/I, C++, Java, VB,...)
• End-user
– who accesses the database via
•
•
written application program or
a query language
• Data Administrator/Designer (senior level staff)
– determines what data should be stored
– establishes policies for maintaining and dealing
• Database Administrator (DBA) (lower level staff–IT person)
– creates the actual database
– implements technical controls
– monitors performance of the system
Spring-1415
21
22
Spring-1415
Classification of Dbs ( by # of users)
Classification of DBs (by use)
• Transactional (or production):
• Single-user Database
– standalone desktop database
– support only one user at a time
– runs on PC
– Supports a company’s day-to-day operations
• Data warehouse:
• Workgroup Database
– a workgroup is a relatively small team of people who collaborate on the same project or
application
– local area network (<25,50 users), client/server, two-tier
– Stores data used to generate information required to
make tactical or strategic decisions
– Often used to store historical data
– Structure is quite different
• Department Database
– support the various functions and activities of a department
– local area network (25-100 users), client/server, three-tier
• Enterprise Database
– ERP works with the current operational data
– wide-area network (hundreds or thousands of users), client/ distributed or parallel server
– Data warehouses
• Internet Databases
– Web server
Spring-1415
23
Spring-1415
24
6
Classification of DBs (by location)
Data Models
• Collection of logical constructs used to represent/store
• Other classifications:
– data (structure) : Staffs and Branches
– relationships : Who is working in which branch ?
• Centralized (uses a single computer with one db)
• Distributed (uses multiple computers, multiple db)
• Conceptual models: (ER Model)
– logical nature of data representation
• Implementation models: (Database Models)
– emphasis on how the data are represented in the database
– each DBMS adopts a data model
•
•
•
•
•
Spring-1415
25
Hierarchical Model and IMS System (mid 1960-1980)
Network Model - CODASYL/COBOL (1970 – 1980)
Relational Model (early 1970-...)
Object-Oriented Model (1990-...)
Object-Relational Model (1990-...)
26
Spring-1415
Evolution of Major Data Models
Hierarchical Model
• The hierarchical data model
organizes data in a Tree
Structure.
• represented by an upside-down “tree”
• There is a hierarchy of parent
and child data segments.
– Each parent can have many
children
– Each child has only one parent
• Connected Graphs with Cycles
not allowed
Spring-1415
27
Spring-1415
28
7
Network Model
Relational Model
• The network data model was created to represent
complex data relationships more effectively than the
hierarchical model
• Data model is a simple network,
• Graphs Allowed
• Relational Model of Data is
based on the concept of a
Relation
• Relation - a Mathematical
Concept Based on Sets
• RELATION: A Table of Values
– A Relation may be thought of
as a Set of Rows / a Set of
Columns
– Each Row of the relation may
be given an Identifier
– Each Column typically is called
by its Column Name
29
Spring-1415
30
Spring-1415
Entity-Relationship Model
Object Oriented Model
• Data and relationships are contained in a single structure :
object
• OODM (object-oriented data model) is the basis for
OODBMS
• Widely accepted standard for data modeling
• Relational model lacks some features to be an effective
database design tool.
– designers prefer to use a graphical tool
• Semantic data model
• An object:
• data (structure) and their relationships are pictured.
• Contains data and operations
• Are self-contained: a basic building-block for autonomous structures
• Is an abstraction of a real-world entity
• Entity relationship diagram (ERD)
– Uses graphic representations to model data
BRANCH
BranchNo
Street
City
PostCode
Spring-1415
12527
SL21
John
White
Manager
:
:
12345
STAFF
Works
StaffNo
fName
lName
position
sex
31
Spring-1415
24526
SLG37
Ann
Reach
Assistant
:
:
66666
73652
SLG14
David
Ford
Supervisor
:
:
66666
12345
b005
22 Deer Road
London
SW1 4EH
66666
B003
163 Main St
Glasgow
G119QX
32
8
Architecture of Database Systems
ANSI-SPARC Architecture (Three-Schema Architecture)
• Major goal
– Provide
• Data independence
• users with an abstract view of data
External
View #1
External
View #2
Conceptual (logical) Schema
• ANSI-SPARC architecture
– Most existing commercial database management
systems are based on this architecture
Internal Schema
Disk 1
Spring-1415
External
View #3
33
Spring-1415
Disk 2
Disk 3
34
Three Levels of ANSI-SPARC Architecture
Differences Between Three Levels
• Conceptual level:
– Contains the logical structure of
the entire database
– Independent of any physical
storage considerations
– Represents:
• All entities, their attributes, and
their relationships
• Constraints on the data
– Supports each external view
Spring-1415
35
Spring-1415
36
9
Three Levels of ANSI-SPARC Architecture
Three Levels of ANSI-SPARC Architecture
• External Level
• Internal level:
– The way users perceive the
data
– Different users may have
different views of the
same data
– The physical
representation of the
database on the computer
– Describes how the data is
stored in the database;
• External view content of
the database as seen by a
particular user
• Storage space allocation
• Data structures and file
organizations used to store
data on storage devices
Ex: at least two views for “I
was born in 1/22/1980”
• Date of birth
• Age: 23 years old
Spring-1415
37
Data Independence
Spring-1415
38
Advantages of Three-Level Architecture
• Major objective of three-level architecture:
• All users should be able to access same data
• A user’s view is not affected by changes of other users’
views
• Users don’t need to know physical database storage
details
• Database Administrator (DBA) should be able to change
database storage structures without affecting the users’
views
• DBA should be able to change conceptual structure of
database without affecting all users
– Data independence:
– upper levels are unaffected by changes to lower levels
• Physical data independence: the measure of how much the
conceptual schema is unaffected by changes in the internal
schema
– Single Conceptual/Internal mapping
• … defines the correspondence b/w conceptual view and stored database
• If storage structure is changed then conceptual/internal mapping must also be
changed by DBA
• Logical data independence: the measure of how much the
external schemas are unaffected by changes in the conceptual
schema
– Several External/Conceptual mappings
• … define the correspondence b/w external views and the conceptual view
Spring-1415
39
Spring-1415
40
10