-
Theory
-
SQL vs NoSQL (Relational vs non-relational)
-
Web-scaled
-
When to use SQL and NoSQL
-
Expression, Statement, Operators
-
Data types SQL
- null, bit
- int, real / float
- char, varchar, text
- boolean
- date, datetime, timestamp
- xml/json
- – char vs varchar vs text
- – datetime vs timestamp
- – JSON vs JSONB
-
Operators
-
Arithmetic, Logical, Comparison, Bitwise
-
Primitives: Integer, Numeric, String, Boolean
-
Structured: Date/Time, Array, Range / Multirange, UUID
-
Document: JSON/JSONB, XML, Key-value (Hstore)
-
Geometry: Point, Line, Circle, Polygon
-
Customizations: Composite, Custom Types
-
Postgres
-
complex queries
- Aggregation
- Subquery
- Window Function
-
foreign keys
-
triggers
- Trigger Timing
- - BEFORE and AFTER
- - Uses
-
updatable views
-
transaction integrity
-
multiversion concurrency control
-
functions
- Stored Procedures
- Window functions
- Aggregate functions
-
operators
-
aggregate functions
-
index methods
-
procedural language
-
Forks
-
client/server model
-
Data types Unique to Postgres
- interval
- point
- bigserial
- etc…
-
Database cluster
-
Constraints
- UNIQUE
- NOT NULL
- PRIMARY KEY
- as UUID
- FOREIGN KEY
- CHECK (<condition>)
- - Adding & removing constraints after creating table
-
Commands
- list db
- to connect
- list tables
- Move to super
- list specific table
- List current table
-
Creating
- Database
- Table
-
Drop
- Drop DB
- Drop Table
- Drop constraints
-
Commands
- – or /* */
- Database migration
- Add, Delete, Migration
- Up migration
- Dow migration
-
Functions
- SELECT
- LIMIT
- FETCH
- OFFSET
- AS
- DISTINCT
- GROUP BY
- HAVING
- GROUPING SETS
- ROLLUP
- CUBE
- Having vs Where
- Limit vs Fetch
- FROM
- WHERE
- AND, OR
- LIKE, ILIKE
- BETWEEN
- IN
- IS NULL, IS NOT NULL
- ORDER BY
- DESC, ASC
- DELETE
- DELETING FOREIGN KEY
- CASCADE
- UPDATE
- SET
- RENAME COLUMN
- JOIN
- INNER JOIN
- ON
- LEFT JOIN
- RIGHT JOIN
- FULL JOIN (FULL OUTER JOIN)
- SELF JOIN
- CROSS JOIN
- NATURAL JOIN
- VIEWS
- Pros and Cons
- CREATE VIEW
- Materialized View
- Write amplification
- UNION
- COALESCE
- NULLIF
- Index
- multi index
-
AUTO_INCREMENT
-
ON CONFLICT
- DO NOTHING
- Upserting
- - DO UPDATE
- EXCLUDED
-
Date functions
- INTERVAL vs AGE
-
Aggregate functions
- AVG, MIN, MAX, SUM, ROUND, COUNT, CONCAT
-
Scalar Functions
- LCASE, CASE, LEN, MID, ROUND, NOW, FORMAT ,
- INITCAP , LEFT , RIGHT , CONCAT , ABS , CEIL , FLOOR,
- UPPER AND LOWER in psql.
-
Aggregate vs Scalar
-
Window function
- OVER
- - PARTITION BY, RANK, LEAD, LAG
- CASE
-
SQL Commands
- DDL
- CREATE, ALTER, DROP, TRUNCATE
- DROP vs TRUNCATE
- DML
- INSERT, SELECT, UPDATE, DELETE
- DCL
GRANT, REVOKE
- TCL
- COMMIT
- ROLLBACK
- SAVE POINT
- DQL
- SELECT
-
3-Schema architecture
- Internal level
- Conceptual level
- External level
-
BIGINT VS BIGSERIAL
-
Combining queries
- UNION, UNION ALL
- INTERSECT, INTERSECT ALL
- EXCEPT, EXCEPT ALL
-
Normalisation
- Levels
- 1NF, 2NF, 3NF etc..
- BCNF
- Anomalies
- - Insertion anomalies
- Data redundancy
- Missing data
- - Deletion anomalies
- Losing data
- - Updation anomalies
- inconsistency
- Updating values on so many records unnecessarily
-
Relationship
- one to one
- one to many
- many to may
-
Transaction & ACID
-
- Transaction
- COMMIT
- ROLLBACK
- SAVE POINT
- RELEASE SAVEPOINT
- LOCK
- Exclusive Locks (X-Locks)
- Shared Locks (S-Locks)
- Update Locks (U-Locks)
- Intent Locks
- Read and Write Locks
-
- ACID
- - Atomicity
- - Consistency
- Consistency in data
- Consistency in reads
- - Isolation
- Read phenomena
- - Dirty reads
- - Non-repeatable reads
- - Phantom reads
- Serialotions
- - (Lost updates)
- Isolation level
- - Read uncommitted
- - Read committed
- - Repeatable Reads
- - Transactions are Serialized
- - Durability
- How to implement ACID properties
-
EXPLAIN
-
Heap Scan
-
Parallel Scan
-
Planner
-
Other theory and functions
-
COPY
-
OLTP
-
MUCC
-
Pendings
-
Delete vs truncate
-
candidate key vs super key
-
stored procedure
-
ER diagram.
-
Practice nested queries.