4.3 Create a Table (TRANSACTIONS)

The TRANSACTIONS table contains a row for each transaction involving a patron and a book (for example, someone checking a book out or returning a book). It includes two foreign key columns.

  1. In the SQL Worksheet, enter the following statement:

    CREATE TABLE transactions (
       transaction_id NUMBER,
       patron_id CONSTRAINT for_key_patron_id
          REFERENCES patrons(patron_id),
       book_id CONSTRAINT for_key_book_id
          REFERENCES books(book_id),
       transaction_date DATE
          CONSTRAINT tran_date_not_null NOT NULL,
       transaction_type NUMBER
          CONSTRAINT tran_type_not_null NOT NULL,
       CONSTRAINT transactions_pk PRIMARY KEY (transaction_id));
  2. Click the Run Statement icon.

    The following notification is displayed in the Script Output pane:

    Table TRANSACTIONS created.