-- CSE 154
-- Week 9: Bricker and Morter (PHP and SQL)

-- This table represents a "shopping cart" for a single customer. It references
-- the Inventory table in the bmstore database to link items in a shopping cart
-- with their corresponding information in the Inventory table. This makes it
-- much easier to avoid redundancy between the two tables in our database!
DROP TABLE IF EXISTS MyCart; -- warning: each time we source this file, all existing data is irreversibly dropped.
CREATE TABLE MyCart(
  -- AUTO_INCREMENT allows us to avoid setting this explicitly each time we insert
  cid         INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, 
  pid         INTEGER,
  lastupdated DATETIME,
  qty         INTEGER,
  FOREIGN KEY (pid) REFERENCES Inventory (id)
);

