Skip to content
UoL CS Notes

Introduction to SQL

COMP207 Lectures

Relational Databases

  • Data is organised into tables.
    • Tables have a table name.
    • Tables have attributes (columns).
      • All elements in a column are of the same datatype.
    • Tables have tuples (rows).
    • Each table has a schema. This lists the attributes of a table e.g:
      • Items(name,price,number)

Tables

Tables typically have:

  • Few columns that are fixed.
  • A variable number of rows.

Rows

Each row corresponds to an entity, or a relationship between entities.

  • Each row corresponds to the same kind of entity or relation.
    • This could be a table of many employees details or many transactions.
  • If two rows are the same they are the same item, as opposed to two identical items.

SQL

Relational databases are accessed using SQL (standard query language). This standard is updated every few years but implementations may not exactly follow the standard.

SQL Parts

  • Data Definition Language (DDL)
    • Create/alter/delete databases, tables and their attributes.
  • Data Manipulation Language (DML)
    • Add/remove/update and query rows in tables.
  • Transact-SQL
    • Completing a sequence of SQL statements.