CREATE TABLE S
(
	S#	VARCHAR2(5),
	SNAME	VARCHAR2(15) NOT NULL,
	STATUS	NUMBER(4) NOT NULL,
	CITY	VARCHAR2(20) NOT NULL,
	CONSTRAINT PK_S PRIMARY KEY (S# )
);

CREATE TABLE P
(
	P#	VARCHAR2(5),
	PNAME	VARCHAR2(15) NOT NULL,
	COLOR   VARCHAR2(10),
	WEIGHT	NUMBER(4),
	CITY	VARCHAR2(20) NOT NULL,
	CONSTRAINT PK_P PRIMARY KEY (P# )
);

CREATE TABLE J
(
	J#	VARCHAR2(5),
	JNAME	VARCHAR2(15) NOT NULL,
	CITY	VARCHAR2(20) NOT NULL,
	CONSTRAINT PK_J PRIMARY KEY (J# )
);

CREATE TABLE SPJ
(	
	S#	VARCHAR2(5),
	P#	VARCHAR2(5),
        J#	VARCHAR2(5),
        QTY	NUMBER(5) NOT NULL,
	CONSTRAINT PK_SPJ PRIMARY KEY (S#, P#, J#)
);


ALTER TABLE SPJ
 ADD CONSTRAINT FK_S_SPJ
 FOREIGN KEY (S#)
 REFERENCES S (S#);

ALTER TABLE SPJ
 ADD CONSTRAINT FK_P_SPJ
 FOREIGN KEY (P#)
 REFERENCES P(P#);

ALTER TABLE SPJ
 ADD CONSTRAINT FK_J_SPJ
 FOREIGN KEY (J#)
 REFERENCES J (J#);
