A database is an organised collection of related data. A DBMS (Database Management System) is the software that stores, retrieves, updates and protects that data (e.g., MySQL, Oracle, MS Access). Compared with keeping separate files, a DBMS reduces redundancy (repeated data), keeps data consistent, and controls access.
Relational model (proposed by E. F. Codd): data is stored in tables (relations).
- Row = record or tuple; column = field or attribute.
- Degree = number of columns; cardinality = number of rows.
- Primary key: uniquely identifies each row; it cannot be empty (NULL) or repeated.
- Candidate key: any column(s) that could serve as the primary key; the ones not chosen are alternate keys.
- Foreign key: a column that refers to the primary key of another table, linking the two.
SQL command groups: DDL — CREATE, ALTER, DROP (structure); DML — INSERT, UPDATE, DELETE (data), with SELECT for queries (sometimes listed separately as DQL); DCL — GRANT, REVOKE (permissions); TCL — COMMIT, ROLLBACK (transactions).
Worked example: Table Students(RollNo, Name, Class) has 3 columns and 40 rows, so degree = 3, cardinality = 40. RollNo is the natural primary key. To list names of Class 8 students: SELECT Name FROM Students WHERE Class = 8;
Other terms: normalisation splits tables to remove redundancy; transactions follow ACID — Atomicity, Consistency, Isolation, Durability.
Common confusions: DELETE removes rows (DML) while DROP removes the whole table (DDL); a foreign key may repeat, a primary key may not; degree counts columns, cardinality counts rows.