Monday, October 31, 2022

 CREATE TABLE SAILORS(SID NUMBER,SNAME VARCHAR2(10),RATING NUMBER(2),AGE NUMBER(4,2));

ALTER TABLE SAILORS ADD CONSTRAINT PK_SAILORS PRIMARY KEY(SID);

DESC SAILORS;

CREATE TABLE BOATS (BID NUMBER,BNAME VARCHAR2(10),COLOR VARCHAR2(10));

ALTER TABLE BOATS ADD CONSTRAINT PK_BOATS PRIMARY KEY(BID);

CREATE TABLE RESERVES(SID NUMBER,BID NUMBER,DAY DATE);

ALTER TABLE RESERVES ADD CONSTRAINT PK_RESERVES PRIMARY KEY(SID,BID,DAY);

ALTER TABLE RESERVES ADD CONSTRAINT FK_RESERVES FOREIGN KEY(SID) REFERENCES SAILORS(SID);

ALTER TABLE RESERVES ADD CONSTRAINT FK_RESERVES1 FOREIGN KEY(BID) REFERENCES BOATS(BID);

DESC RESERVES;

DESC BOATS;

INSERT INTO SAILORS VALUES(22,'DUSTIN',7,45.0);

INSERT INTO SAILORS VALUES(29,'BRUTUS',1,33.0);

INSERT INTO SAILORS VALUES(31,'LUBBER',8,55.5);

INSERT INTO SAILORS VALUES(32,'ANDY',8,25.5);

INSERT INTO SAILORS VALUES(58,'RUSTY',10,35.5);

INSERT INTO SAILORS VALUES(64,'HORATIO',7,35.0);

INSERT INTO SAILORS VALUES(71,'ZORBA',10,16.0);

INSERT INTO SAILORS VALUES(74,'HORATIO',9,35.0);

INSERT INTO SAILORS VALUES(85,'ART',3,25.0);

INSERT INTO SAILORS VALUES(95,'BOB',3,63.5);

COMMIT;

SELECT * FROM SAILORS;

INSERT INTO BOATS VALUES(101,'INTERLAKE','BLUE');

INSERT INTO BOATS VALUES(102,'INTERLAKE','RED');

INSERT INTO BOATS VALUES(103,'CLIPPER','GREEN');

INSERT INTO BOATS VALUES(104,'MARINE','RED');

SELECT * FROM BOATS;

INSERT INTO RESERVES VALUES(22,101,'10-OCT-1998');

INSERT INTO RESERVES VALUES(22,102,'10-OCT-1998');

INSERT INTO RESERVES VALUES(22,103,'10-AUG-1998');

INSERT INTO RESERVES VALUES(22,104,'10-JUL-1998');

INSERT INTO RESERVES VALUES(31,102,'11-OCT-1998');

INSERT INTO RESERVES VALUES(31,103,'11-JUN-1998');

INSERT INTO RESERVES VALUES(31,104,'11-DEC-1998');

INSERT INTO RESERVES VALUES(64,101,'09-MAY-1998');

INSERT INTO RESERVES VALUES(64,102,'09-AUG-1998');

INSERT INTO RESERVES VALUES(74,103,'09-AUG-1998');

SELECT * FROM RESERVES;



 DBMS class materials click here to join the class room  click here  https://www.youtube.com/channel/UC93Sqlk_tv9A9cFv-QjZFAQ