Database Management Systems: Instructor: Murali Mani Mmani@cs - Wpi.edu
Database Management Systems: Instructor: Murali Mani Mmani@cs - Wpi.edu
Chapter 1
Instructor: Murali Mani mmani@cs.wpi.edu
What is a database?
A very large, integrated collection of data. Models real-world application :
Usually data is too large to fit into main memory, and often used by many users
Database applications ?
E-commerce : Amazon.com, etc. Airlines and travel services Scientific data such as biology, oceanography, etc. Spatial data such as maps, travel networks, World Wide Web Digital libraries of artifacts of any kind
What is a DBMS ?
DBMS stands for Database Management System software package designed to store, manage and provide access to databases.
Digital libraries, interactive video, Human Genome project, EOS project ... need for DBMS exploding
A data model :
is a collection of concepts for describing data.
A schema :
is a description of a particular collection of data, using the given data model.
Levels of Abstraction
Many views:
Views describe how users see the data.
View 1
View 2
View 3
Conceptual Schema
Conceptual schema defines logical structure Physical schema describes the files and indexes used.
Physical Schema
Conceptual schema:
Students(sid: string, name: string, login: string, age: integer, gpa:real) Courses(cid: string, cname:string, credits:integer) Enrolled(sid:string, cid:string, grade:string)
Physical schema:
Relations stored as unordered files. Index on first column of Students. Course_info(cid:string, enrollment:integer) CS542Students(sid: string, grade:string)
Data Independence *
Applications insulated from how data is structured and stored. Logical data independence:
Stage large datasets between main memory and secondary storage (buffering, pageoriented access) Must write special code for different queries Must protect data from inconsistency due to multiple concurrent users Must manage crash recovery in some special-purpose manner Must provide good methods for access control
Concurrency Control
Because disk accesses are frequent, and relatively slow, it is important to keep CPU humming by working on several user programs concurrently.
Key Concepts of CC
Key concept is transaction, which is an atomic sequence of multiple database actions (reads/writes)
If system crashes in the middle of a Xact, then DBMS ensures atomicity Idea: Keep a log (history) of all actions carried out by the DBMS while executing a set of Xacts:
Before a change is made to database, corresponding log entry is forced to a safe location (commit of transaction) After a crash, the effects of partially executed transactions are undone using the log (rollback of transaction)
E.g., smart webmasters Designs logical /physical schemas Handles security and authorization Data availability, crash recovery Database tuning as needs evolve
Must understand how a DBMS works!
Structure of a DBMS
Query Optimization and Execution Relational Operators Files and Access Methods
Buffer Management
DB
Summary
DBMS used to maintain & query large datasets. Benefits include recovery from system crashes, concurrent access, quick application development, data integrity and security. Levels of abstraction give data independence. A DBMS typically has a layered architecture.
DBAs hold rewarding jobs. DBMS R&D is one of the broadest, most exciting areas in CS.
Introductory Material
Sets, Relations and Functions
Sets
Unordered collection of objects Characteristics
Eg: Set of passengers, set of flights Recall the main set operations
Relations
Given multiple sets A1, A2, , An, a relation is a set of n-tuples of the form (a11, a12, , a1n), where a11 is an element of A1, a12 is an element of A2, and so on. Eg: suppose the set of course = {DB1, DB2}, the set of TAs = {Hong, Song}, then a relation between these two sets could be {(DB1, Hong), (DB1, Song), (DB2, Hong)}
Functions
Given two sets A, B, a function f from A to B is denoted as f: A B. This maps any value of A to one value of B.
Eg: consider function from faculty members to depts {(Mike Gennert CS), (Peter Hansen Humanities)}
Characteristics
A is called domain B is called range No value of A can map to multiple Bs.
Functions
Surjections (onto)
Every value in B has at least 1 value in A that maps to it
Bijections
One to one and onto