Date post: | 05-Apr-2018 |
Category: |
Documents |
Upload: | intellectual-kilian |
View: | 217 times |
Download: | 0 times |
of 43
8/2/2019 Lecture1mgaya
1/43
Silberschatz, Korth and Sudarshan1.1Database System Concepts
1
RCS 201:
Database Design3 unit courseLecturer Mr Mgaya Gervas B
RUAHACOLLEGE
UNIVERSITY
8/2/2019 Lecture1mgaya
2/43
RCS 201 Database Design 2
OBJECTIVES OF THE COURSE
To provide students with an awareness of the need for adatabase system, its role in an organization and thestandard database management system (DBMS)architecture.
To provide students with skills to analyse databaserequirement and design well-structured relational databasedesigns
8/2/2019 Lecture1mgaya
3/43
RCS 201 Database Design 3
LEANING OUTCOMES
At the end of this course you should be able to:
1. Explain what is a database
2. Discuss the advantage and disadvantages of database
and explain the architecture of databases
3. Describe the different approaches to database designand list down the advantages of the relational modeldesign
4. Perform INF,2NF, and BCNF normalization, ER andEER modelling
5. Design and implement well-structured relationaldatabase
8/2/2019 Lecture1mgaya
4/43
RCS 201 Database Design 4
Assessment modality
The course will be assessed as follows:
Lectures and practicals attendance: 10marks
Two individual timed tests @ 15 marks= 30
Total coursework 40%
NOTE: THERE WILL BE NO MAKE UP WHAT SO EVER!
WORK HARD!
8/2/2019 Lecture1mgaya
5/43
RCS 201 Database Design 5
TEXTBOOKS1. Elmasri,Ramez & Shamkant Fundamental of
Database Systems
2. Date, C.J Introduction to Database Systems
REFERENCE BOOKS1.SilberschatzKorthSudarshan Database
System Concepts, Fourth Edition
8/2/2019 Lecture1mgaya
6/43
Silberschatz, Korth and Sudarshan1.6Database System Concepts
6
Plan for Intro to DB Systems I
What is:
A database
Data A database management system (DBMS)
Reading:
Chapter 1 of the textbook
8/2/2019 Lecture1mgaya
7/43Silberschatz, Korth and Sudarshan1.7Database System Concepts
7
Definition of Data (Datum)
Data is a value of a property of an individual UoD object or arelationship (between two UoD objects) at a particular period oftime
Example
UoD object(s) James James & CompSci
Property Age Number of Points
Time Feb 2007 Feb 2007
Value 21 240
8/2/2019 Lecture1mgaya
8/43Silberschatz, Korth and Sudarshan1.8Database System Concepts
8
Definition of a Database
A database is a collection of related data
Essential database characteristics are:
-Represents an aspect of the real world (miniworld,Universe of
Discourse (UoD)), Well structured (even has a strict regular structure),
Reflects (or should reflect) current state of the UoD,
Has users and applications, and
Stored in a permanent (persistent) computer memory
Managed by a Database Management System (DBMS)
All these characteristics have to be met
8/2/2019 Lecture1mgaya
9/43Silberschatz, Korth and Sudarshan1.9Database System Concepts
9
What Is a Database?
RealWorld
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
more facts
more facts
more facts
more facts
more facts
more facts
more facts
more facts
more facts
more facts
some more rather long facts about the world in the databse
some more rather long facts about the world in the databse
some more rather long facts about the world in the databse
some more rather long facts about the world in the databse
some more rather long facts about the world in the databse
some more rather long facts about the world in the databse
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
Database
Facts about world and behaviour of world
represented incontents and operations of a database
Users
8/2/2019 Lecture1mgaya
10/43Silberschatz, Korth and Sudarshan1.10Database System Concepts
10
A Sample Database
Studen
t
LName FName StudId Major
Smith Susan 131313 Comp
Bond James 007007 Math
Smith Susan 555555 CompCourse
CName CourId Hours Dept
DB Sys C302 2+1 Comp
SofEng C301 2+0 Comp
DisMat M214 4+1 Math
Grade
StudId CourId Grade
007007 C302 A+
007007 C301 A
007007 M214 A+
131313 C301 B-
555555 C301 C
131313 C302 D
555555 C302 E
8/2/2019 Lecture1mgaya
11/43Silberschatz, Korth and Sudarshan1.11Database System Concepts
11
Database Application Areas
Database Applications: Banking: all transactions
Airlines: reservations, schedules
Universities: registration, grades
Sales: customers, products, purchases
Manufacturing: production, inventory, orders, supply chain
Human resources: employee records, salaries, tax deductions
Databases touch all aspects of our lives
8/2/2019 Lecture1mgaya
12/43Silberschatz, Korth and Sudarshan1.12Database System Concepts
12
Database Management System (DBMS)
A database management system (DBMS) is a
collection of programs that enables users to createand maintain a database.
The DBMS is hence a general-purpose softwaresystem that facilitates the processes of defining,
constructing, and manipulating databases forvarious applications.
Defining a database involves specifying the datatypes, structures, and constraints for the data to be
stored in the database.
Constructing the database is the process ofstoring the data itself on some storage medium thatis controlled by the DBMS.
Manipulating a database includes such functions
8/2/2019 Lecture1mgaya
13/43Silberschatz, Korth and Sudarshan1.13Database System Concepts
13
Database Management System (DBMS)
In a nutshell,
A collection of programs that enable:
Defining (describing the structure),
Populating by data (Constructing),
Manipulating (querying, updating), Preserving consistency,
Protecting from misuse,
Recovering from failure, and
Concurrent using
of a database.
8/2/2019 Lecture1mgaya
14/43Silberschatz, Korth and Sudarshan1.14Database System Concepts
14
A Simplified Database System Layout
Application Programs/Interactive Queries
Catalog Database
Query ProcessorData
Access
DBMS
DatabaseSystem
Users/Programmers
DatabaseDescription
DDL
Compiler
DBA
8/2/2019 Lecture1mgaya
15/43Silberschatz, Korth and Sudarshan1.15Database System Concepts
15
Database system=database +DBMS
Why do We Use a DBMS?
Suppose we need to build a universityinformation system. How do we
Store the data? (use file structure..) Query the data? (write a programme..) Update the data safely?(write more programmes..) Provide different views on the same data? Deal with crashes?
8/2/2019 Lecture1mgaya
16/43Silberschatz, Korth and Sudarshan1.16Database System Concepts
16
Purpose of Database System
In the early days, database applications were built on top of filesystems
Drawbacks of using file systems to store data:
Data redundancy and inconsistency
Multiple file formats, duplication of information in different files
Difficulty in accessing data
Need to write a new program to carry out each new task
Data isolation multiple files and formats
Integrity problems
Integrity constraints (e.g. account balance > 0) become partof program code
Hard to add new constraints or change existing ones
8/2/2019 Lecture1mgaya
17/43Silberschatz, Korth and Sudarshan1.17Database System Concepts
17
Purpose of Database Systems (Cont.)
Drawbacks of using file systems (cont.)
Atomicity of updates
Failures may leave database in an inconsistent state with partialupdates carried out
E.g. transfer of funds from one account to another should eithercomplete or not happen at all
Concurrent access by multiple users
Concurrent accessed needed for performance
Uncontrolled concurrent accesses can lead to inconsistencies
E.g. two people reading a balance and updating it at the same
time Security problems
Database systems offer solutions to all the above problems
8/2/2019 Lecture1mgaya
18/43Silberschatz, Korth and Sudarshan1.18Database System Concepts
18
When Not to Use a DBMS
In spite of the advantages of using a DBMS, there are a few
situations in which such a system may involve unnecessaryoverhead costs as that would not be incurred in traditional fileprocessing. The overhead costs of using a DBMS are due to thefollowing:
High initial investment in hardware, software, and
training. Generality that a DBMS provides for defining and
processing data.
Overhead for providing security, concurrency control,recovery, and integrity functions.
8/2/2019 Lecture1mgaya
19/43Silberschatz, Korth and Sudarshan1.19Database System Concepts
19
3 Levels of Abstraction
1.Physical level describes how a record (e.g., customer) is stored.
2.Logical level: describes data stored in database, and therelationships among the data.
type customer = recordname: string;street: string;city: integer;
end;
3. View level: application programs hide details of data types.Views can also hide information (e.g., salary) for security
purposes.
8/2/2019 Lecture1mgaya
20/43Silberschatz, Korth and Sudarshan1.20Database System Concepts
20
View of Data
An architecture for a database system
8/2/2019 Lecture1mgaya
21/43Silberschatz, Korth and Sudarshan1.21Database System Concepts
21
Instances and Schemas
Similar to types and variables in programming languages
Schema the logical structure of the database e.g., the database consists of information about a set of customers and
accounts and the relationship between them)
Analogous to type information of a variable in a program
Physical schema: database design at the physical level
Logical schema: database design at the logical level
Instance the actual content of the database at a particular point in time
Analogous to the value of a variable
Physical Data Independence the ability to modify the physical schemawithout changing the logical schema
Applications depend on the logical schema
In general, the interfaces between the various levels and components should bewell defined so that changes in some parts do not seriously influence others.
8/2/2019 Lecture1mgaya
22/43Silberschatz, Korth and Sudarshan1.22Database System Concepts
Semantic data models attempt to capture the
meaning of a database. Practically, they provide anapproach for conceptual data modeling.
Over the years there have been several differentsemantic data models that have been proposed.
By far the most common is the entity-relationshipdata model, most often referred to as simply the E-Rdata model.
The E-R model is often used as a form ofcommunication between database designers and theend users during the developmental stages of adatabase.
Introduction to Data Modeling
8/2/2019 Lecture1mgaya
23/43Silberschatz, Korth and Sudarshan1.23Database System Concepts
23
Data Models
Data models is a collection of tools for describing data
data relationships
data semantics
data constraints
Entity-Relationship model Conceptual model to identify data & important relationships
Relational model
mathematical model based on set-theory
Most commercial DBMSs are based on it Other models:
Object-oriented model, Object-relational model
semi-structured data models Older models: network model and hierarchical model
8/2/2019 Lecture1mgaya
24/43
Silberschatz, Korth and Sudarshan1.24Database System Concepts
24
Entity-Relationship Model
Example of schema in the entity-relationship model
8/2/2019 Lecture1mgaya
25/43
Silberschatz, Korth and Sudarshan1.25Database System Concepts
25
Entity Relationship Model (Cont.)
E-R model of real world
Entities (objects)
E.g. customers, accounts, bank branch
Relationships between entities
E.g. Account A-101 is held by customer Johnson
Relationship set depositorassociates customers with accounts Widely used for database design
Produces specification of the data and relationship to maintain in thedatabase.
Database design in E-R model usually converted to design in the
relational model (coming up next) which is used for storage andprocessing
8/2/2019 Lecture1mgaya
26/43
Silberschatz, Korth and Sudarshan1.26Database System Concepts
26
Relational Model
Example of tabular data in the relational model
customer-name
Customer-idcustomer-street
customer-city
account-number
Johnson
Smith
Johnson
Jones
Smith
192-83-7465
019-28-3746
192-83-7465
321-12-3123
019-28-3746
Alma
North
Alma
Main
North
Palo Alto
Rye
Palo Alto
Harrison
Rye
A-101
A-215
A-201
A-217
A-201
Attributes
8/2/2019 Lecture1mgaya
27/43
Silberschatz, Korth and Sudarshan1.27Database System Concepts
27
A Sample Relational Database
8/2/2019 Lecture1mgaya
28/43
Silberschatz, Korth and Sudarshan1.28Database System Concepts
28
Data Definition Language (DDL)
Specification notation for defining the database schema
E.g.create tableaccount(
account-number char(10),balance integer)
DDL compiler generates a set of tables stored in a data
dictionary
Data dictionary contains metadata (i.e., data about data)
database schema
Data storage and definitionlanguage
language in which the storage structure and access methodsused by the database system are specified
Usually an extension of the data definition language
8/2/2019 Lecture1mgaya
29/43
Silberschatz, Korth and Sudarshan1.29Database System Concepts
29
Data Manipulation Language (DML)
Language for accessing and manipulating the data organized by
the appropriate data model DML also known as query language
Two classes of languages
Procedural user specifies what data is required and how to getthose data
Nonprocedural user specifies what data is required withoutspecifying how to get those data
SQL is the most widely used query language
8/2/2019 Lecture1mgaya
30/43
Silberschatz, Korth and Sudarshan1.30Database System Concepts
30
SQL
SQL: widely used non-procedural language
E.g. find the name of the customer with customer-id 192-83-7465select customer.customer-namefrom customerwhere customer.customer-id= 192-83-7465
E.g. find the balances of all accounts held by the customer with
customer-id 192-83-7465select account.balancefrom depositor, accountwhere depositor.customer-id= 192-83-7465 and
depositor.account-number = account.account-number
Application programs generally access databases through one of
Language extensions to allow embedded SQL
Application program interface (e.g. ODBC/JDBC) which allow SQLqueries to be sent to a database
D b U
8/2/2019 Lecture1mgaya
31/43
Silberschatz, Korth and Sudarshan1.31Database System Concepts
31
Database Users
Users are differentiated by the way they expect to interact with
the system Application programmers interact with system through DML
calls
Sophisticated users form requests in a database querylanguage
Specialized users write specialized database applications thatdo not fit into the traditional data processing framework
Nave users invoke one of the permanent applicationprograms that have been written previously
E.g. people accessing database over the web, bank tellers, clericalstaff
D b Ad i i
8/2/2019 Lecture1mgaya
32/43
Silberschatz, Korth and Sudarshan1.32Database System Concepts
32
Database Administrator
Coordinates all the activities of the database
system; the database administrator has a goodunderstanding of the enterprises information
resources and needs.
Database administrator's duties include:
Schema definition
Storage structure and access method definition
Schema and physical organization modification
Granting user authority to access the database
Specifying integrity constraints
Acting as liaison with users
Monitoring performance and responding to changes inrequirements
T i M
8/2/2019 Lecture1mgaya
33/43
Silberschatz, Korth and Sudarshan1.33Database System Concepts
33
Transaction Management
A transactionis a collection of operations that
performs a single logical function in a databaseapplication
Transaction-management component ensures thatthe database remains in a consistent (correct) state
despite system failures (e.g., power failures andoperating system crashes) and transaction failures.
Concurrency-control manager controls the interactionamong the concurrent transactions, to ensure the
consistency of the database.
St M t
8/2/2019 Lecture1mgaya
34/43
Silberschatz, Korth and Sudarshan1.34Database System Concepts
34
Storage Management
Storage manager is a program module that provides
the interface between the low-level data stored in thedatabase and the application programs and queriessubmitted to the system.
The storage manager is responsible to the following
tasks: interaction with the file manager
efficient storing, retrieving and updating of data
DBMS A hit t
8/2/2019 Lecture1mgaya
35/43
Silberschatz, Korth and Sudarshan1.35Database System Concepts
35
DBMS Architecture
Disk Space Management
Buffer Management
File and Access Methods
Relational Operators
Query Optimizer
Query Parser
Client API
Client
DB
ExecutionEngine
Concurrencyand Recovery
Disk
K I M Hi h
8/2/2019 Lecture1mgaya
36/43
Silberschatz, Korth and Sudarshan1.36Database System Concepts
36
Key Issues: Memory Hierarchy
CPU Cache
Main Memory
Hard Disk
Tape/CD
PriceGoes Up
SpeedGoes Down
ReliabilityGoes Up
D t il d O ll S t St t
8/2/2019 Lecture1mgaya
37/43
Silberschatz, Korth and Sudarshan1.37Database System Concepts
37
Detailed Overall System Structure
Application Architectures
8/2/2019 Lecture1mgaya
38/43
Silberschatz, Korth and Sudarshan1.38Database System Concepts
38
Application Architectures
Two-tier architecture: E.g. client programs using ODBC/JDBC tocommunicate with a databaseThree-tier architecture: E.g. web-based applications, and
applications built using middleware
T D t b G
8/2/2019 Lecture1mgaya
39/43
Silberschatz, Korth and Sudarshan1.39Database System Concepts
39
Top Database Groups
Academia:
1) Stanford University, 2) University of Wisconsin, Madison,3) University of California, Berkeley, 4) University ofMaryland, College Park, 5) University of Washington.
Research Labs:
1) IBM Almaden Research Lab, 2) AT&T Research Labs, 3)Microsoft Research Lab, 4) Lucent Technologies.
Database Products:
1) Oracle, 2) IBM DB2, 3) MySQL, 4) Sybase, 5) MS SQL
Server, 6) Informix.
Database Professionals
8/2/2019 Lecture1mgaya
40/43
Silberschatz, Korth and Sudarshan1.40Database System Concepts
40
Database Professionals
Database implementers
Build modules that go inside the DBMS
Students in ICOM 6005
Database application developers
Build application that run on top of the DBMS, and are used by end-users to interact with their data.
Students in ICOM 5016
Database Administrators
Create database schema
Maintain and tune the DBMS engine
Maintain and tune the data in the DBMS
Students in ICOM 5016
Corporations need them ($$$)
SUMMARY
8/2/2019 Lecture1mgaya
41/43
Silberschatz, Korth and Sudarshan1.41Database System Concepts
41
SUMMARY
In this presentation we defined a database as a collection ofrelated data, where data means recorded facts.
A typical database represents some aspect of the real worldand is used for specific purposes by one ormore groups ofusers. A DBMS is a generalized software package for
implementing and maintaining a computerized database. Thedatabase and software together form a database system.
We identified several characteristics that distinguish thedatabase approach from traditional file-processingapplications:
Summary continue
8/2/2019 Lecture1mgaya
42/43
Silberschatz, Korth and Sudarshan1.42Database System Concepts
42
Summary continue..
Existence of a catalog.
Program-data independence and program-operationindependence.
Data abstraction.
Support of multiple user views.
Sharing of data among multiple transactions.
We then discussed the main categories of database users, or the"actors on the scene":
Administrators.
Designers. End users.
System analysts and application programmers.
Summary conti
8/2/2019 Lecture1mgaya
43/43
Summary conti... We noted that, in addition to database users, there are
several categories of support personnel, or "workers behindthe scene," in a database environment:
DBMS system designers and implementers.
Tool developers.
Operators and maintenance personnel.
We listed some additional advantages of the database approachover traditional file-processing systems:
potential for enforcing standards.
Reduced application development time.
Flexibility.
Availability of up-to-date information to all users.
Economies of scale.