Relational Model

Data is organised into relations (tables). Each table has rows (tuples) and columns (attributes).

Keys

  • Primary Key: Unique identifier for each row.
  • Foreign Key: References a primary key in another table.
  • Candidate Key: Any column that can be a primary key.
  • Super Key: Any set of attributes that uniquely identifies a row.

Basic SQL

SELECT name, salary FROM employees WHERE department = 'IT' ORDER BY salary DESC;nnINSERT INTO employees (name, salary) VALUES ('Ram', 45000);nnUPDATE employees SET salary = 50000 WHERE name = 'Ram';nnDELETE FROM employees WHERE name = 'Ram';