Database Fundamental

Gong Haibing
Gong HaibingBackend Developer/Leader/DevOps at Guangzhou Sponia Software Co., Ltd
Database Fundamental
@dylanninin
What is a Database?
an organized collection of data.
Database
What is a DBMS?
a software application.
DataBase Management System
History
Database Fundamental
Database Fundamental
Let’s talk about RDBMS
Database Models
Relational Model
Relational Model
Relational Relationships
SQL
• SQL: Structure Query Language
• The Language for RDBMS
• Define/Manipulate/Control data
Relational Algebra
• The Set-theoretic formulation of RDBMS
• The Theory/Mathematics of SQL
Relational Algebra
SQL
Database Fundamental
Twitter as an example
with SQLite
Database Fundamental
DDL: Data Definition Language
DDL: CREATE
DDL: ALTER
DDL: TRUNCATE
• deletes all data from a table in a very fast way
• deletes the data inside the table and not the table itself
• usually implies a subsequent COMMIT operation, i.e.
• cannot be rolled back
DDL: DROP
The Data Types
DDL: Data Manipulation Language
DML: SELECT
expr
DML: SELECT join
Database Fundamental
DML: SELECT Phases
DML: INSERT
DML: UPDATE
DML: DELETE
DML: MERGE
• is used to combine the data of multiple tables
• combines the INSERT and UPDATE elements
• is defined in the SQL:2003 standard
• some databases provided similar functionality via different
syntax, sometimes called "upsert"
TCL: Transaction Control Language
TCL: Transaction
TCL: COMMIT
TCL: ROLLBACK
TCL: SAVEPOINT
DCL: Data Control Language
DCL: Control
• The operations for which privileges may be granted to or
revoked from a user or role apply to both the DDL/DML
• may include CONNECT, SELECT, INSERT, UPDATE,
DELETE, EXECUTE, and USAGE
• SQLite does not have any DCL commands as it does not
have usernames or logins. Instead, SQLite depends on file
system permissions to define who can open and access a
database
DCL: GRANT
by Oracle
DCL: REVOKE
by Oracle
Functions
• definition: function_name(parameter) —> output
• usage: SELECT function_name(parameter);
Aggregrations
avg(X) returns the average value of all non-NULL X within a group
count(X)
returns a count of the number of times that X is not NULL in
a group
max(X) returns the maximum value of all values in the group
min(X)
returns the minimum non-NULL value of all values in the
group
sum(X) return sum of all non-NULL values in the group
Constraints
Constraints: Foreign Key
Constraints: Indexed Column
Indexing
Triggers
Views
Modeling
Entity Relation Diagram
ERD to Table
Database Fundamental
Normalization
Advanced Topics
Transaction
A
balance: $ 1000
B
balance: $ 1000
Transfer 100$ from A to B
Bank withdraw/deposit
Transactions guaranteed by ACID
ACID Properties
by locking + logging
by runtime checking
by locking
by logging + recovery
ACID Implements
Concurrency
A
balance: $ 1000
B
balance: $ 1000
1) A transfer $100 to B

2) C transfer $1 000 to A
C
balance: $ 1 000 000
Transaction states
Two Phase Locking
Two Phase Locking
Dead Lock
Optimistic Concurrency Control
Multi Version Concurrency Control
Isolation Level
Data Structures + Algorithms
Database Fundamental
Database Fundamental
Common Data Structure Operations
Search: SELECT
Search: LIKE
Sort: ORDER BY
Algorithms: B+ Tree
B+ Tree
B+ Tree Example
B+ Tree Index Example
B+ Tree in Database
DBMS
a software application.
DataBase Management System
What are the “Kernel” of any DBMS?
“Kernel”
Client Manager
Query Manager
Data Manager
Cache Manager
Transaction Manager
Log Manager
Simplified ARIES logs
Simplified Log Writing Process
Tuning
SQL Tuning Hierarchy
SQL Phases
Scaling
Vertical/Horizontal Scaling
Scaling Out Cube
Partitioning
Master Slave
Replica Set
Distributed
CAP
Paxos Protocol
Raft Protocol
Database Fundamental
Reference
• https://en.wikipedia.org/wiki/SQL
• https://en.wikipedia.org/wiki/Database
• https://en.wikipedia.org/wiki/ACID
• https://www.sqlite.org/lang.html
• https://en.wikipedia.org/wiki/Join_(SQL)
• http://coding-geek.com/how-databases-work/
• http://blog.dancrisan.com/a-tiny-intro-to-database-systems
• http://berb.github.io/diploma-thesis/original/060_index.html
• https://en.wikipedia.org/wiki/CAP_theorem
• https://github.com/numetriclabz/awesome-db
• https://github.com/rxin/db-readings
• http://bigocheatsheet.com/
• https://en.wikipedia.org/wiki/BNF
• https://dylanninin.com/blog/2013/10/26/oracle_dba.html
1 of 112

More Related Content

What's hot(20)

operating system structureoperating system structure
operating system structure
Waseem Ud Din Farooqui49.1K views
Types of keys in dbmsTypes of keys in dbms
Types of keys in dbms
darshhingu812 views
Flow chart vs dfdFlow chart vs dfd
Flow chart vs dfd
Wardah AK4.6K views
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
Dr. C.V. Suresh Babu7.3K views
Data dictionaryData dictionary
Data dictionary
Surbhi Panhalkar34.7K views
Case study operating systemsCase study operating systems
Case study operating systems
Akhil Bevara18.2K views
Database basicsDatabase basics
Database basics
prachin5144.5K views
Database systemsDatabase systems
Database systems
NazmulHossen5270 views
Database fragmentationDatabase fragmentation
Database fragmentation
Punjab College Of Technical Education32.9K views
Concurrency Control.Concurrency Control.
Concurrency Control.
Amity International Business School2.9K views
Distributed operating system(os)Distributed operating system(os)
Distributed operating system(os)
Dinesh Modak20.7K views
Advanced sqlAdvanced sql
Advanced sql
Dhani Ahmad3K views
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers10K views
MYSQL.pptMYSQL.ppt
MYSQL.ppt
webhostingguy40.1K views
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde3.5K views
SQLSQL
SQL
Shunya Ram3.6K views

Similar to Database Fundamental

Sql serverSql server
Sql serverPuja Gupta
408 views19 slides
Module02Module02
Module02Sridhar P
830 views42 slides
6_SQL.pdf6_SQL.pdf
6_SQL.pdfLPhct2
13 views102 slides

Similar to Database Fundamental(20)

Sql – pocket guideSql – pocket guide
Sql – pocket guide
Santhosh Kumar480 views
Sql serverSql server
Sql server
Puja Gupta408 views
PT- Oracle session01 PT- Oracle session01
PT- Oracle session01
Karthik Venkatachalam397 views
Module02Module02
Module02
Sridhar P830 views
6_SQL.pdf6_SQL.pdf
6_SQL.pdf
LPhct213 views
Dbms & oracleDbms & oracle
Dbms & oracle
J VijayaRaghavan722 views
dbs class 7.pptdbs class 7.ppt
dbs class 7.ppt
MARasheed34 views
lovelylovely
lovely
love0323452 views
Structure Query Language (SQL).pptxStructure Query Language (SQL).pptx
Structure Query Language (SQL).pptx
NalinaKumari223 views
Structure query language (sql)Structure query language (sql)
Structure query language (sql)
Nalina Kumari196 views
SQL_NOTES.pdfSQL_NOTES.pdf
SQL_NOTES.pdf
AnshumanDwivedi1442 views
Introduction to SQLIntroduction to SQL
Introduction to SQL
Ehsan Hamzei77.8K views
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
Gowarthini351 views
Complete first chapter rdbm 17332Complete first chapter rdbm 17332
Complete first chapter rdbm 17332
Tushar Wagh1.3K views
DbmsDbms
Dbms
philipsinter462 views
Getting Started with SQL Language.pptxGetting Started with SQL Language.pptx
Getting Started with SQL Language.pptx
Cecilia Brusatori18 views

More from Gong Haibing

Nginx EssentialNginx Essential
Nginx EssentialGong Haibing
924 views53 slides
How to Code ReviewHow to Code Review
How to Code ReviewGong Haibing
439 views44 slides
Search EngineSearch Engine
Search EngineGong Haibing
288 views57 slides

More from Gong Haibing(9)

Ansible IntroductionAnsible Introduction
Ansible Introduction
Gong Haibing219 views
Nginx EssentialNginx Essential
Nginx Essential
Gong Haibing924 views
How to Code ReviewHow to Code Review
How to Code Review
Gong Haibing439 views
A Byte of Software DeploymentA Byte of Software Deployment
A Byte of Software Deployment
Gong Haibing390 views
Sponia with QingCloudSponia with QingCloud
Sponia with QingCloud
Gong Haibing297 views
Search EngineSearch Engine
Search Engine
Gong Haibing288 views
Jenkins-CIJenkins-CI
Jenkins-CI
Gong Haibing750 views
Linux FundamentalLinux Fundamental
Linux Fundamental
Gong Haibing853 views
Git RealGit Real
Git Real
Gong Haibing696 views

Recently uploaded(20)

Thanks Giving Encouragement Wednesday.pptxThanks Giving Encouragement Wednesday.pptx
Thanks Giving Encouragement Wednesday.pptx
FamilyWorshipCenterD8 views
SOA PPT ON SEA TURTLES.pptxSOA PPT ON SEA TURTLES.pptx
SOA PPT ON SEA TURTLES.pptx
EuniceOseiYeboah7 views
Al Kindi.pptxAl Kindi.pptx
Al Kindi.pptx
MubbaraShahzadi5 views
CitSciOz MOUA Inspiring Change Through ArtCitSciOz MOUA Inspiring Change Through Art
CitSciOz MOUA Inspiring Change Through Art
Christian Bartens37 views
Salvation a Work of GodSalvation a Work of God
Salvation a Work of God
Central Church of Christ16 views
Prospectus (1).pdfProspectus (1).pdf
Prospectus (1).pdf
PancrazioScalambrino12 views

Database Fundamental