Working with Multiple Tables

Most databases contain multiple tables

  • This is a direct result of normalization

Use keys to determine relationships between rows in different tables

  • A primary key identifies a unique row in a table
  • A foreign key references a row in another table

Create foreign key constraints to enforce referential integrity

  • This prevents invalid data insertions
  • It can be used to prevent deletions or updates that will “orphan” rows

The procedure while working with multiple tables

  • Use the CREATE TABLE statement to create tables
  • Use the INSERT statement to add rows to a table
  • Use the SELECT statement to retrieve rows from a table
  • Use constraints that define relationships between primary keys and foreign keys to enforce referential integrity

results matching ""

    No results matching ""