Lecture 1 - Introduction To Databases
Lecture 1 - Introduction To Databases
1
Course content
2
Course materials
•Textbook: Database Systems: The complete book. (Second) by
Garcia Molina, Ullman and Widom, ISBN: [9780131354289].
Pearson
•Slides: found on Google Classroom
•Exercises and labs: to be published on Google Classroom
•Programming tools: XAMPP, NetBeans with Java JDK
3
Some rules
• You should constantly check your email/google classroom announcements.
• “Not seeing your email” is not a valid excuse. You have a smartphone.
• Emails should be sent to me in English or Arabic. “Arabizi” emails won’t get
a reply.
4
CENG375
Introduction to Database Systems
Chapter 1
World of Database Systems
5
Some questions
• What is in your opinion the best way to organize the data and where?
• How will we search the data to find what we need?
6
Database World
• Database is nothing more than a collection of information that exists over
a long period of time, often many years.
• Databases are used to maintain and manage Data found in:
• Websites
• Corporations
• Research institutes
• Companies
7
Real life examples
8
Database World
• Databases are involved with almost every business in the world
• Almost any website has a database behind the scene that serve up the
information you request such as Facebook to store your comments,
statuses, and friends
• Corporations maintain all their important records in databases
9
Database Management System
(DBMS)
• The power of databases comes from a powerful software that has
10
DBMS properties
1.Allows users to create new databases and specify their
structure
2.Allows users to Query the data and modify it (CRUD)
3.Supports storage of large amounts of data over a long
period of time
4.Ensures durability and recovery
5.Controls access to databases: Assign rights to users
6.Allows execution of transactions: isolation and atomicity
11
Database Management System
• A DBMS allows users to query and modify data:
• Example of a user: A java application, a web application, etc..
• Query data: Retrieve and read data from the database
• Modify data: Insert new data (or Create), update and delete
• Acronym CRUD: Create, read, update and delete
12
Evolution of DBMS
1 Early Database Systems
• Evolved from file systems and date back to 1960’s
• Not all DBMS properties are offered
• First important applications of DBMS:
• Banking systems
• Airline Reservation systems
• Corporate record keeping
13
Evolution of DBMS
2 Relational Database Systems
• Relational Model was born in 1970 by a famous paper written by Ted Codd
• Data organized as tables called relations
• The programmers are not involved with the storage structure
• Queries are expressed in a high-level language called SQL
Relation:
Title Year Genre Director
Movies
James
Tuple 1 Avatar 2009 Adventure
Cameron
W Halla2 la
Tuple 2 2011 Drama/comedy Nadine Labaki
wein?
14
Example of a relational database School
• A relational database is a collection of relations (Tables)
Relation Teachers
TeacherID name age
1 John smith 33
2 Jane white 40
In the above example, the database school has 3 tables. in Table teachers, we have 2 tuples denoting 2
teachers, john and jane. In table courses, we have 2 courses, and in table teach, we have 3 tuples that tell us
that john teaches ceng375 and ceng380, while jane only teaches 375
15
Evolution of DBMS
• Due to advances in technology, we can store gigabytes on single disks
now
• DBMS can be run on personal computers now
16
Evolution of DBMS
17
Evolution of DBMS
• Examples of document databases: JSON and XML
18
Relational data versus
document store data
19
Evolution of DBMS
• When to use a relational (SQL) database?
• Structured data where relationship between entities is important: Relational databases
require one to follow a schema
• When to use a non-relational (NoSQL) database
• If the data you are storing needs to be flexible in terms of shape or size, or if it needs to
be open to change in future
• NoSQL database systems accept some duplication of data
• Other comparison criteria: Scalability and data storage, complexity and speed of
queries execution, reliability, …
20
The SQL language
•SQL is the most important query language based on
relational model.
•It’s used to issue commands to the DBMS
•SQL = Structured Query Language
•The SQL standard is around since the 1970s
•Lots of features, we will only see a subset
21
SQL command types
• DDL: Data definition language
• Used by database administrator to define the structures of a database like This
schema, tables, constraints, etc. course
22
• The key distinction is that the DDL
command is used to create a database
schema, while the DML command is
used to retrieve data from the database
and to modify the content of the table
(data).
23
Basic DDL Commands in SQL
•CREATE: to define new tables (relation schemas)
•DROP: to remove tables from the database
•ALTER: to change the definitions of existing tables (to change
relation schema)
•Other features of DDL: Specify constraints
ALTER example:
TeacherID name birthdate
age phone
24
Basic DML Commands in SQL
•INSERT (CREATE new data records): to add new rows to tables
•UPDATE: to change the “state” (the value) of rows.
•DELETE: to remove rows
•SELECT (READ): a query command that retrieves data from the
database
Acronym CRUD is used to refer to DML operations: Create, Read,
Update, and Delete
TeacherID name birthdate
age phone
1 John Smith
W Smith 1990 71777675
81999999
2 Jane White 1983 71888888
25
Concept of a query
26
Overview of DBMS
• A DBMS has several components that work together to execute SQL commands
27
The Query Processor
✓ Translates the query into a query plan which is a sequence of
operations to be performed on the data.
28
Storage manager
• Data access: keeps track of the location of files on the disk and
obtains the blocks of data upon request.
• Buffer manager: A database buffer is a memory location used by a
DBMS to temporarily hold data that has recently been accessed or
updated in the database.
• It acts as a link between the programs accessing the data and the
physical storage devices.
• The buffer is essential for enhancing the DBMS's overall performance:
• Caching frequently requested data in memory decreases the
frequency of disc I/O operations, accelerating query and
transaction processing. 29
Transaction manager
30
Transaction manager
32