
CREATE TABLE student(
  ssn INTEGER PRIMARY KEY,
  name VARCHAR(30),
  address VARCHAR(50));

CREATE TABLE class(
  c_id CHAR(6) PRIMARY KEY,
  c_name VARCHAR(20),
  units INTEGER);

CREATE TABLE takes(
  ssn INTEGER NOT NULL,
  c_id CHAR(6) NOT NULL,
  grade INTEGER,
  FOREIGN KEY (ssn) REFERENCES student(ssn),
  FOREIGN KEY (c_id) REFERENCES class(c_id),
  PRIMARY KEY(ssn, c_id));

INSERT INTO student(ssn, name, address)
  VALUES(123, "Smith", "Main St");
INSERT INTO student(ssn, name, address)
  VALUES(234, "Jones", "College Ave");

INSERT INTO class(c_id, c_name, units)
  VALUES('15-413', 'Databases', 3);
INSERT INTO class(c_id, c_name, units)
  VALUES('15-412', 'Information Technology', 3);

INSERT INTO takes(ssn, c_id, grade)
  VALUES(123, '15-413', 4);
INSERT INTO takes(ssn, c_id, grade)
  VALUES(234, '15-413', 3);

