Notes
Outline
What is a DBMS
Database management systems:
Provide efficient and secure access to large amounts of data.
Address problems such as:
How to store the data
How to query data efficiently
How to update the data securely (by multiple users)
Contrast with using file systems for the same task
Relational Databases
Based on the relational model
Separates the logical view from the physical view of the data.
Querying a Database
Find all the students who have taken 94.301 in Fall 2001.
S(tructured) Q(uery) L(anguage)
select E.name
from Enroll E
where E.course=94.301 and
           E.quarter=“Fall 2001”
Query processor figures out how to answer the query efficiently.
Database Industry
Relational databases are a great success of theoretical ideas.
“Big 3” DBMS companies are among the largest software companies in the world.
IBM (with DB2) and Microsoft (SQL Server, Microsoft Access) are also important players.
$20B industry
Challenged by object oriented DBMS.
Functionality of a DBMS
Storage management
Abstract data model
High level query and data manipulation language
 Efficient query processing
Transaction processing
Resiliency: recovery from crashes
Interface with programming languages
Why Use a DBMS?
Data independence and efficient access.
Reduced application development time.
Data integrity and security.
Uniform data administration
Concurrent access and recovery from crashes.
The Study of DBMS
Several aspects:
Modeling and design of databases
Database programming: querying and update operations
Database implementation
DBMS study cuts across many fields of Computer Science: OS, languages, AI, Logic, multimedia, theory...
Database Design
Why do we need it?
 Agree on structure of the database before deciding on a particular implementation.
Consider issues such as:
What entities to model
How entities are related
What constraints exist in the domain
How to achieve good designs
Database Design Formalisms
Object Definition Language (ODL):
 Closer in spirit to object-oriented models
Entity/Relationship model (E/R):
More relational in nature.
Both can be translated (semi-automatically) to relational schemas (with varying amount of pain).
ODL to OO-schema: direct transformation (C++ or Smalltalk based system).
Object Definition Language
Is part of ODMG, which also gave us OQL.
Resembles C++ (and Smalltalk).
Basic design paradigm in ODL:
Model objects and their properties.
For abstraction purposes:
Group objects into classes.
What qualifies as a good class?
Objects should have common properties.
ODL Class Declarations
ODL Example
ODL Declarations
ODL Example
ODL Declarations
ODL Example
ODL Declarations
Types in ODL
Allowable Types in ODL
Entity / Relationship Diagrams
Slide 21
Multi-way Relationships
Roles in Relationships
Attributes on Relationships
What’s Wrong?
What’s Wrong?
Do we really need 3-way relationships?
The Relational Data Model
Terminology
More Terminology
More on Tuples
Updates
From ODL to Relational Schema
Adding Non atomic Attributes
Set Attributes
Modeling Collection Types
Modeling Relationships
Option #1
Hint
Better Solution
From E/R Diagrams to Relational Schema
Slide 42
Entity Sets to Relations
Relationships to Relations
Problems in Designing Schema
Relation Decomposition
Decompositions in General
Boyce-Codd Normal Form
Example
And Now?
What About This?
Let’s Decompose!
More Careful Strategy
Example Decomposition
Decomposition Based on BCNF is Necessarily Correct
Multivalued Dependencies
SQL Introduction
Selections
Projections
Ordering the Results
Joins
Disambiguating Attributes
Tuple Variables
Union, Intersection, Difference
Subqueries
Subqueries Returning Relations
Conditions on Tuples
Correlated Queries
Removing Duplicates
Conserving Duplicates
Aggregation
Grouping and Aggregation
HAVING Clause
Modifying the Database
More Interesting Insertions
Deletions
Updates
Defining Views
A Different View