Chapter 3
Chapter 3
A database is an organized collection of data that allows easy access, management, and
updating.
Term Description
Table (Relation) A collection of related data in rows & columns.
Row (Tuple) A single record in a table.
Column (Attribute) A specific field in a table.
Primary Key A unique identifier for each record.
Foreign Key A field that refers to the primary key of another table.
sql
Copy
CREATE TABLE Students (
ID INT PRIMARY KEY,
Name VARCHAR(50),
Age INT
);
sql
Copy
CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
CustomerID INT,
FOREIGN KEY (CustomerID) REFERENCES Customers(ID)
);
Candidate Key: A set of unique columns that can be the primary key.
Super Key: A candidate key + additional attributes.
Forms of Normalization:
ACID Properties:
sql
Copy
START TRANSACTION;
UPDATE Accounts SET Balance = Balance - 500 WHERE AccountID = 1;
UPDATE Accounts SET Balance = Balance + 500 WHERE AccountID = 2;
COMMIT; -- Finalizes the transaction
Summary of Chapter 3
DBMS stores, manages, and retrieves data efficiently.
Relational Database Model (RDBMS) organizes data in tables.
SQL is used for database queries.
Keys (Primary, Foreign, Candidate) define relationships between tables.
Normalization reduces redundancy and improves data integrity.
Transactions & ACID properties ensure database reliability.