CS 220 P
Topic 0: Introduction
Professor Sharad Mehrotra
DBH 2091
949 824 5975
Office Hours: by appointment
Loc: DBH 2091
1
Outline
2
CS 220P Course Website
3
Teaching Assistants
Office hour: Mon 1-3pm
CompSci 220P
Shiyuan Zhou (szhou20@uci.edu),
Keming Li (kemingl1@uci.edu)
DATA 220P
Nada Lahjouji (nlahjouj@uci.edu)
4
Course Textbook
5
6
Course Requirements
7
Assignments
8
Exams
9
Academic Honesty Requirement
10
Class Discussions & Interactions
11
Material Covered in CS 220P
Database Course Menu @ UCI
12
MCS
CS 220P --- grad level 122A
CS 222P – MS. Version of 222
CS223P – MS. Version of 223
CS 224P – intro to big data
UNDERGRADUATE
CS 122A ---- SQL
CS 122B --- advanced web based applications
CS 122 C ---- same as 222
CS 122D ----- new/emerging data systems
Grad Classes
CS 222 --- implementing databases
CS 223 -- transactions, distributed databases
CS 224 -- emerging research trends in DBMS
Database Management Environment
13
Applications/queries
Query processor
Storage manager
User
Metadata
Database
Database: Collection of interrelated information about the world being modeled.
DBMS: General purpose software to define, create, modify, retrieve, delete and manipulate a database
Vendors: Oracle, IBM, Microsoft. Amazon, Google, Cloud based solutions by SalesForce, Couchbase, Aerospike…...
DBMS
The Paleolithic Period … pre database systems era
14
Consistency Example
Consider a withdraw application that read the account balance, deducts money, and writes the new account balance.
Now consider Tom and Jerry executing the deduct application concurrently.
In file systems, the last writer “wins” !
If both Tom and Jerry read the balance prior to the other updating it, irrespective who who writes last, the balance is wrong!
Unlike file systems DBMS do not allow such inconsistencies to occur!
15
Reliability Example
Consider that you are able to get a ticket for the FIFA world cup finals in New Jersey
So you reserve a ticket from Orange County to EWR
The reservation is written into the file
Unfortunately, an untimely power outage prevents the file from being saved, or worse,
causes the file to be corrupted.
you are denied the flight with no evidence of reservation (airline sold your seat to someone else)
you lose your money!
Unlike file systems, database systems provide guarantees that applications effects are not lost despite all types of failures!
16
The Neolithic Period…the arrival of Database Systems
17
Data Model
18
Schema versus Instance
19
(John, 10), (Cindy, 15), (Martha, 10)
(10, Toy, John), (15, Sales, Cindy)
Dept
SCHEMA
Tables
Emp (ename, dep#)
Dept(dep#, dname, mgr)
Constraints
each department has
a single manager
Instance
The Dark Ages ….
20
The Relational Era..
21
21
Relational Model
22
Customer-
name
Customer-id
Customer-
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
A Sample Relational Database
23
Data Abstraction supported by Relational Model
24
Physical Level
Logical Level
View1
View 2
View n
Physical description of data and storage organization
higher level representation
(that describes logical structure of data)
Customized views
(that describe how users see data). Closer to how applications may view data
Data Independence
The ability to write programs at one level of abstraction and have the programs still work when a lower-level changes.
25
Examples
26
Types of Data Model
27
Entity-Relationship Model
28
Depositor
Customer
Customer-id
Customer-name
Customer-street
Customer-city
Account
Account-number
Balance
Entity Relationship Model (Cont.)
29
Data Definition Language (DDL)
30
Simple Query Language -- Algebra & Calculus
Customer(CustomerID, Name, City, Age)
Relational Algebra
πName(σCity=′Irvine′ ∧ Age>30(Customer))
Relational Calculus
{t.Name ∣ t∈Customer ∧ t.City=′Irvine′ ∧ t.Age>30}
31
SQL -- intergalactic Data Speak!
32
SQL in the DML Role
Inserting Data:
INSERT into account values (‘one’, 10), (‘two’,20);
Retrieving Data:
SELECT * from account;
Basic SQL has limited expressibility
Application programs generally access databases through one of
33
Data Wars (1)
34
Data Wars (2)
35
Era of Object-Oriented Programming
36
Pointer’s Strike Back…
37
Application
data structures
Relational
representation
RDBMS
Copy and
translation
Transparent
ODBMS
data transfer
Object Oriented Databases
38
CS 220P
Notes 01
38
Disadvantages of ODBMS Approach
39
CS 220P
Notes 01
39
POSTGRES
40
CS 220P
Notes 01
40
The Return of the Relations … POSTGRES
41
CS 220P
Notes 01
41
bought by
commercialized
Dawn of New Era - the World Wide Web!
42
CS 220P
Notes 01
42
OID1: {
name → "Sharad",
affiliation → OID2 }
OID2: {
dept → "CS",
univ → "UCI" }
{
"name": "Sharad",
"affiliation": {
"dept": "CS",
"univ": "UCI"
}
}
OEM Graph (Stanford)
JSON tree
And then Came the Clouds….
led to two major developments.
UCI played a major role in both….
43
Cloud Databases and Serverless Computing
Motivation: Scalability, elasticity, zero-maintenance
•Key Systems: Snowflake, BigQuery, Redshift, Aurora, CosmosDB
•Takeaway: Data-as-a-service, disaggregation of storage/compute
44
NetDB2 - Database Service
(Feb, 2002)
45
For Us: Maintenance and Administration!
Database as a Service, Hacigumus, Iyer, Mehrotra, ICDE 2002
Internet Scale Applications…
•led to the big-data & NoSQL movement.
•Key Systems: GFS, MapReduce, Bigtable, Hadoop, MongoDB, Cassandra
•Takeaway: One-size-fits-all broken → Polyglot systems
46
AsterixDB System Overview
47
ASTERIX Cluster
Hi-Speed Interconnect
AQL queries/results
Data loads and feeds from external sources
Data publishing
47
Asterix Client Interface
AQL Compiler
Metadata Manager
Hyracks Dataflow Engine
Dataset / Feed Storage
LSM Tree Manager
…..
Asterix Client Interface
AQL Compiler
Metadata Manager
Hyracks Dataflow Engine
Dataset / Feed Storage
LSM Tree Manager
(ADM = ASTERIX Data Model;
AQL = ASTERIX Query Language)
The return of SQL in Big Data
•Motivation: Analysts love SQL
•Key Systems: Hive, Spark SQL, Spanner, Presto, Snowflake
•Takeaway: SQL reasserts itself on distributed, cloud-native systems
48
And Now to the current times … AI/ML and Data Systems
Motivation: Data is fuel for AI
•Key Systems: Feature stores, vector DBs (FAISS, Pinecone, Milvus), RAG pipelines
•Takeaway: DBs evolving into AI-native infrastructure
SQL & Relational databases still remain the most important building blocks of modern data infrastructures.
Next class: Peek inside relational database systems
49
The AI progress - the new revolution
For now, note that relational system remains the most important data management technology to date, and most No/New SQL have roots in the relational databases.
Next class: Peek inside relational database systems
50
CS 220P
Notes 01
50
51
CS 220P
Lecture 2: A peek into the DBMS technology … �
Relational Databases
53
How Relational Databases Work
54
Layered Structure of a DBMS
55
Lock
Manager
Transaction
Manager
Query Parser
Query Optimizer
Plan Executor
Relational Operators (+ Utilities)
Files
of
Records
Buffer Manager
Access
Methods
(Indices)
Disk Space and I/O Manager
Log
Manager
Data
Files
Index
Files
Catalog
Files
WAL
SQL
Query plans
API calls
Storage Manager
Key DBMS Components
56
Need for Query Optimization
57
Strategy 1
58
Strategy 2
59
Need for Indexing
60
How indexes help!
61
…
…
<ipad 5, John ,…..$399, 22 Main Sreet.>
<ipad pro, Bob ,…..$999, 22 1st Sreet.>
<ipad 5, Tim ,…..$399, 22 1st Sreet.>
…
…
<ipad 5,ptr.>
<ipad 5,ptr.>
<ipad 10,ptr.>
Index File on product-name
Data File
Large Records – each 1K, 100M records
Large file – 100GB
Small Record – each 16 B, 100M records
small file – 1.6GB
Transaction Concept
62
Example of Transaction
63
Motivation of Isolation
64
Importance of the Transactions
65
Transactions versus Other Concurrent Programming Environments
66
What they offers
67
Key Database Technologies
Powerful Data Models and query languages
Storage Manager, Indexing & Query Processing
Transaction Manager
Views & fine-grained SQL level authorization
CS 220 P
Lecture 2: Introduction to the DBMSs�
Relational Databases
69
Database Management System Architecture
Database and
Indices
Transaction
Manager
Buffer manager
File system
Metadata
and data
dictionary
compilers
evaluator
optimizer
Query processor
Storage manager
Application Queries Schema changes
Key Database Technologies
Storage Media and their Properties
Storage Media and their Properties
Databases and Storage Devices
Virtual memory:
File system:
Functional Abstraction of a Simplistic DBMS
beginT
SQL
SQL
endT
beginT
SQL
SQL
endT
Query Processor
optimizer
Record-oriented file system
Basic file system
Buffer manager
Hardware
SQL statements
Read write records, scan relations
Get page containing tuples
Read/write file pages
Access plan
Basic File System
Basic File System Design Issues
Buffer Management
Database Buffer Management Design Issues
Record-Oriented File System
Mapping Records to Pages
Page header
Tuple 1
Tuple 2
Tuple 3
Tu
ple 4
records grow this way
Directory grows this way
To access a record on a page, access record directory on page to get address of record on page
Mapping Records to Pages
Evolution of Traditional Row Stores
83
Traditional Record Storage
Traditionally, storage was targeted towards On-Line Transaction Processing (OLTP)
Characteristics of OLTP applications:
84
We could further improve write performance using log-structured merge tree
In traditional databases: In-place storage
1234, John Smith
3434, Mary Bla
…
Sailors Table file
1234, John Smith
2344, Peter Che
3434, Mary Bla
…
Sailors Table file
INSERT INTO Sailors VALUES(2344, Peter Che)
Expensive: random disk access for each INSERT (or UPDATE or DELETE)
�Log Structured Merge (LSM) Tree
1234, John Smith
4445, Jay Bla
…
1234, John Smit
3434, Mary Fu
…
…
4353, May Wilson
9879, Ray Smith
2344, Peter Che
INSERT INTO Sailors VALUES(2344, Peter Che)
RAM
HDD/SSD
Insert into memory storage
Periodically Merged (Compacted)
1234, John Smith
434, Mary Fu
4445, Jay Bla
…
Pushed to disk when chunk full
LSM Storage
While LSM trees improved write performance and OLTP workloads, Column stores were designed for OLAP applications
Row and Column Stores
Suited for OLTP.
Insert/delete requires one physical write
Suited for OLAP.
Minimizes reading unnecc. data
Column Stores
File Organization
Index Management and Associative Access
Need for Indexing
Let us see how…..
92
How indexes help!
Much more on indexing later and how it helps ….
93
…
…
<ipad 5, John ,…..$399, 22 Main Sreet.>
<ipad pro, Bob ,…..$999, 22 1st Sreet.>
<ipad 5, Tim ,…..$399, 22 1st Sreet.>
…
…
<ipad 5,ptr.>
<ipad 5,ptr.>
<ipad 10,ptr.>
Index File on product-name
Data File
Large Records – each 1K, 100M records
Large file – 100GB
Small Record – each 16 B, 100M records
small file – 1.6GB
Types of Indices
Organization of Index File
Organization of Index File
B+ Tree Indexes
97
P
0
K
1
P
1
K
2
P
2
K
m
P
m
index entry
Non-leaf
Pages
Pages
(Sorted by search key)
Leaf
Example B+ Tree
98
2*
3*
Root
17
30
14*
16*
33*
34*
38*
39*
13
5
7*
5*
8*
22*
24*
27
27*
29*
Entries < 17
Entries >= 17
Note how data entries
in leaf level are sorted
Hash-Based Indexes
99
Static Hashing
100
h(key) mod N
h
key
Primary bucket pages
Overflow pages
2
0
N-1
Using an Index for Selections
SELECT *
FROM Reserves R
WHERE R.rname < ‘C%’
Query Processing in DBMSs
Parsing and Translation
optimizer
Evaluation engine
Statistics about data
Select …
From …
Where ...
Internal relational algebra based representation of query
Optimized execution plan
Data and index
Sally 4000
Dick 9000
…
…
...
Query results
Need for Query Optimization
Strategy 1
If (E.department == M.department) and (M.mname = “sharad”)
print E.ename
Strategy 2
temp = M.department
print E.ename
Strategy 2 is 10 times better compared to 1.
Optimizer’s Goal: Often “bad” plans can be orders of magnitude worse compared to “good” ones. The optimizer Chooses a ”good” plan from an exponential number of them with the goal to ensure that the chosen plan is ”good” 🡪 might not be the best!
Query Optimization
Cost of Query Execution
Databases Support the Transaction Concept
Example of Transaction
Importance of the Transactions
Transactions versus Other Concurrent Programming Environments
Concurrency Control
112
Consistency Challenge due to Concurrency
Scheduling Concurrent Transactions
114
Ensuring Atomicity
115
The Log
116
117