CREATE DATABASE SPJ;

USE SPJ;

CREATE TABLE S(
SNO VARCHAR(8),
SNAME VARCHAR(32),
STATUS SMALLINT,
CITY VARCHAR(16),
PRIMARY KEY(SNO)
);

CREATE TABLE P(
PNO VARCHAR(8),
PNAME VARCHAR(32),
COLOR VARCHAR(8),
WEIGHT DECIMAL,
PRIMARY KEY(PNO)
);

CREATE TABLE J(
JNO VARCHAR(8) PRIMARY KEY,
JNAME VARCHAR(32),
CITY VARCHAR(16)
);

CREATE TABLE SPJ(
SNO VARCHAR(8),
PNO VARCHAR(8),
JNO VARCHAR(8),
QTY SMALLINT,
FOREIGN KEY (SNO) REFERENCES S(SNO),
FOREIGN KEY (PNO) REFERENCES P(PNO),
FOREIGN KEY (JNO) REFERENCES J(JNO)
);