Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Database Fundamental
@dylanninin
What is a Database?
an organized collection of data.
Database
What is a DBMS?
a software application.
DataBase Management System
History
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
Twitter as an example
with SQLite
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 its...
DDL: DROP
The Data Types
DDL: Data Manipulation Language
DML: SELECT
expr
DML: SELECT join
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 S...
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/...
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 ...
Constraints
Constraints: Foreign Key
Constraints: Indexed Column
Indexing
Triggers
Views
Modeling
Entity Relation Diagram
ERD to Table
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
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
Reference
• https://en.wikipedia.org/wiki/SQL
• https://en.wikipedia.org/wiki/Database
• https://en.wikipedia.org/wiki/ACI...
Database Fundamental
Database Fundamental
Database Fundamental
Database Fundamental
Database Fundamental
Database Fundamental
Database Fundamental
Database Fundamental
Database Fundamental
Upcoming SlideShare
Loading in …5
×

Database Fundamental

568 views

Published on

- Database Concept
- Database History
- Theory and SQL of RDBMS
- Advanced Tops
- Distributed Database and CAP

Database Fundamental

  1. 1. Database Fundamental @dylanninin
  2. 2. What is a Database?
  3. 3. an organized collection of data. Database
  4. 4. What is a DBMS?
  5. 5. a software application. DataBase Management System
  6. 6. History
  7. 7. Let’s talk about RDBMS
  8. 8. Database Models
  9. 9. Relational Model
  10. 10. Relational Model
  11. 11. Relational Relationships
  12. 12. SQL • SQL: Structure Query Language • The Language for RDBMS • Define/Manipulate/Control data
  13. 13. Relational Algebra • The Set-theoretic formulation of RDBMS • The Theory/Mathematics of SQL
  14. 14. Relational Algebra
  15. 15. SQL
  16. 16. Twitter as an example with SQLite
  17. 17. DDL: Data Definition Language
  18. 18. DDL: CREATE
  19. 19. DDL: ALTER
  20. 20. 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
  21. 21. DDL: DROP
  22. 22. The Data Types
  23. 23. DDL: Data Manipulation Language
  24. 24. DML: SELECT
  25. 25. expr
  26. 26. DML: SELECT join
  27. 27. DML: SELECT Phases
  28. 28. DML: INSERT
  29. 29. DML: UPDATE
  30. 30. DML: DELETE
  31. 31. 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"
  32. 32. TCL: Transaction Control Language
  33. 33. TCL: Transaction
  34. 34. TCL: COMMIT
  35. 35. TCL: ROLLBACK
  36. 36. TCL: SAVEPOINT
  37. 37. DCL: Data Control Language
  38. 38. 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
  39. 39. DCL: GRANT by Oracle
  40. 40. DCL: REVOKE by Oracle
  41. 41. Functions • definition: function_name(parameter) —> output • usage: SELECT function_name(parameter);
  42. 42. 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
  43. 43. Constraints
  44. 44. Constraints: Foreign Key
  45. 45. Constraints: Indexed Column
  46. 46. Indexing
  47. 47. Triggers
  48. 48. Views
  49. 49. Modeling
  50. 50. Entity Relation Diagram
  51. 51. ERD to Table
  52. 52. Normalization
  53. 53. Advanced Topics
  54. 54. Transaction
  55. 55. A balance: $ 1000 B balance: $ 1000 Transfer 100$ from A to B Bank withdraw/deposit
  56. 56. Transactions guaranteed by ACID
  57. 57. ACID Properties
  58. 58. by locking + logging by runtime checking by locking by logging + recovery ACID Implements
  59. 59. Concurrency
  60. 60. A balance: $ 1000 B balance: $ 1000 1) A transfer $100 to B
 2) C transfer $1 000 to A C balance: $ 1 000 000
  61. 61. Transaction states
  62. 62. Two Phase Locking
  63. 63. Two Phase Locking
  64. 64. Dead Lock
  65. 65. Optimistic Concurrency Control
  66. 66. Multi Version Concurrency Control
  67. 67. Isolation Level
  68. 68. Data Structures + Algorithms
  69. 69. Common Data Structure Operations
  70. 70. Search: SELECT
  71. 71. Search: LIKE
  72. 72. Sort: ORDER BY
  73. 73. Algorithms: B+ Tree
  74. 74. B+ Tree
  75. 75. B+ Tree Example
  76. 76. B+ Tree Index Example
  77. 77. B+ Tree in Database
  78. 78. DBMS
  79. 79. a software application. DataBase Management System
  80. 80. What are the “Kernel” of any DBMS?
  81. 81. “Kernel”
  82. 82. Client Manager
  83. 83. Query Manager
  84. 84. Data Manager
  85. 85. Cache Manager
  86. 86. Transaction Manager
  87. 87. Log Manager
  88. 88. Simplified ARIES logs
  89. 89. Simplified Log Writing Process
  90. 90. Tuning
  91. 91. SQL Tuning Hierarchy
  92. 92. SQL Phases
  93. 93. Scaling
  94. 94. Vertical/Horizontal Scaling
  95. 95. Scaling Out Cube
  96. 96. Partitioning
  97. 97. Master Slave
  98. 98. Replica Set
  99. 99. Distributed
  100. 100. CAP
  101. 101. Paxos Protocol
  102. 102. Raft Protocol
  103. 103. 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

×