SQL Databases
Introduction to SQL
Section titled “Introduction to SQL”SQL (Structured Query Language) is the standard language for relational database management systems (RDBMS). It is used to store, manipulate, and retrieve data in databases.
Key Concepts
Section titled “Key Concepts”ACID Properties
Section titled “ACID Properties”Transactions in SQL databases are designed to be ACID compliant to ensure data integrity.
- Atomicity: All or nothing. A transaction is treated as a single unit. If any part fails, the entire transaction fails.
- Consistency: Data must meet all validation rules. The database goes from one valid state to another.
- Isolation: Concurrent transactions do not interfere with each other.
- Durability: Once a transaction is committed, it remains committed even in the case of a system failure.
Normalization
Section titled “Normalization”The process of organizing data to minimize redundancy and improve data integrity.
- 1NF (First Normal Form): Atomic values, no repeating groups.
- 2NF: 1NF + no partial dependencies.
- 3NF: 2NF + no transitive dependencies.
Common SQL Databases
Section titled “Common SQL Databases”- PostgreSQL: Advanced, open-source, object-relational database. Known for reliability and feature robustness.
- MySQL: The world’s most popular open-source database. Great for web applications.
- SQLite: C-library that provides a lightweight disk-based database. No separate server process.
Basic SQL Commands
Section titled “Basic SQL Commands”-- Create a tableCREATE TABLE Users ( ID INT PRIMARY KEY, Name VARCHAR(100), Email VARCHAR(100));
-- Insert dataINSERT INTO Users (ID, Name, Email) VALUES (1, 'Alice', 'alice@example.com');
-- Query dataSELECT * FROM Users WHERE Name = 'Alice';