CPSC 603 Database Systems

advertisement
CPSC 603 Database Systems
Lecturer: Laurie Webster II, Ph.D., P.E.
Lecture 1
Introduction to a First Course in Database
Systems
CPSC 603 Database Systems
• What is a Database Management System?
– Manages very large amounts of data
– Supports efficient access to very large amounts
of data
– Supports concurrent access to v.l.a.d
– Supports secure, atomic access to v.l.a.d
CPSC 603 Database Systems
Relational Database Systems
Ted Codd in 1970 wrote a famous paper “A
Relational Model for large shared data banks”
=> database systems changed significantly!!
CPSC 603 Database Systems
Database Systems presented Users with a View of
data organized as tables called Relations
In this course we will concentrate primarily on
Relational Models of Database Systems
CPSC 603 Database Systems
acct#
12345
34567
…….
Relational Model (Table)
name
balance
Sally
1000.21
Sue
245.48
……..
…...
CPSC 603 Database Systems
*
*
Relational Model (Table)
Today Relational Models are used in most
DBMS’s
The columns of relations (tables) are headed
by attributes (acct#, name, balance, type,….)
CPSC 603 Database Systems
Relational Model (Table)
Rows of the relations(tables) are also called tuples
Tuples are a mathematical term
CPSC 603 Database Systems
Relational Model (Table)
Columns
Tuples
Rows
SQL => Structured Query Language
SELECT A1, A2, ………., An
FROM r1, r2, ………….., rm
WHERE p
Relational Algebra

A1, A2, ……., An
( p (r1, r2, ………….., rm ) )
p  predicate , Ai  attributes , ri  relations
CPSC 603 Database Systems
attributes
account balance
12345
1000.00
rows (tuples) 67890
2846.92
……..
……….
type
savings
checking
……….
…… => many more tuples, one for each account
at this bank!!!
CPSC 603 Database Systems
attributes
Accounts accountNo balance
type
12345
1000.00 savings
rows (tuples) 67890
2846.92 checking
……..
………. ……….
SELECT balance
FROM Accounts
WHERE accountNo = 67890;
QUERY: What is the balance of account number
67890 ?
CPSC 603 Database Systems
CPSC 603 Database Systems
SQL QUERY => SELECT account
FROM Accounts
WHERE type = ‘savings’
AND balance < 0;
QUERY: What are the saving accounts with negative
balances?
CPSC 603 Database Systems
SQL QUERY => SELECT account
FROM Accounts
WHERE type = ‘savings’
AND balance < 0;
1. Examine all tuples of the relation Accounts
mentioned in the FROM - clause
2. Pick out those tuples that satisfy some criterion
indicated in the WHERE clause, and
3. Produce as an answer certain attributes of those
tuples, as indicated in the SELECT - clause.
CPSC 603 Database Systems
Major Components of a DBMS:
Query Processor
Storage Manager
Data + Metadata
Transaction Manager
Metadata = information about the structure of the data
If the DBMS is relational then the metadata includes
the names of relations, names of attributes, data types
for these attributes (e.g., integer or character string of
length 20)
Schema
Modifications
Queries
Modifications
Query
Processor
Transactions
Manager
Storage
Manager
Data
Metadata
CPSC 603 Database Systems
*
DATA MODELS
Underlying structure of a database is the data
model
structure => data types, relationships,
constraints that should hold
for the data
Data Models
• Object-based logical models
• Record-based logical models
• Physical models
Object-Based Logical Model
•
•
•
•
Entity-Relationship model (ER Models)
The Object-Oriented model
The Semantic Data Model
The Functional Data Model
E-R Data Models
E-R Model is based on a perception of a real world
that consists of a collection of basic objects called
entities and of relationships among these objects
Entity is a “thing” or “object” in the real world that is
distinguishable from other objects
i.e. a person is an entity
Relationship is an association among several objects
Object-Oriented Model
Object-Oriented Models are based on a collection of
objects
Record-Based Logical Model
• Relational Model (primary focus of this
class)
• Network Models
• Hierarchical Model
Download