Sobes.tech
Intern — Middle

Defining the schema of tables for clients and their orders

livecode

Task condition

Formulate SQL operators that create two tables.

Table customers:

  • id — unique identifier (PRIMARY KEY, auto-generated, SERIAL).
  • name — customer's name (TEXT, NOT NULL).

Table purchases:

  • id — unique order identifier (PRIMARY KEY, auto-generated, SERIAL).
  • customer_id — foreign key referencing the customers table (INTEGER, NOT NULL).
  • purchase_date — date of order placement (TIMESTAMP, NOT NULL).

The foreign key customer_id should reference the id field of the customers table.