0% found this document useful (0 votes)
8 views4 pages

KhinZarDBMS Practical

The document outlines the creation of four tables in a database: 's', 'p', 'j', and 'spj', along with their respective fields and primary keys. It includes SQL commands for inserting sample data into these tables, representing students, products, jobs, and a relationship between them. The 'spj' table serves as a junction table linking students, products, and jobs with quantity information.

Uploaded by

komchilinn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

KhinZarDBMS Practical

The document outlines the creation of four tables in a database: 's', 'p', 'j', and 'spj', along with their respective fields and primary keys. It includes SQL commands for inserting sample data into these tables, representing students, products, jobs, and a relationship between them. The 'spj' table serves as a junction table linking students, products, and jobs with quantity information.

Uploaded by

komchilinn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Name – Khin Zar Chi Linn

Roll No -III.IT-26
Date – 4.3.2025
DBMS Practical
1.
CREATE TABLE `s` (
`SID` varchar(10) NOT NULL,
`SNAME` varchar(50) DEFAULT NULL,
`STATUS` int DEFAULT NULL,
`CITY` varchar(50) DEFAULT NULL,
PRIMARY KEY (`SID`)
);
INSERT INTO `s` VALUES ('S1','Smith',20,'London'),('S2','Jones',10,'Paris'),
('S3','Blake',30,'Paris'),('S4','Clark',20,'London'),('S5','Adams',30,'Athens');

2.
CREATE TABLE `p` (
`PID` varchar(10) NOT NULL,
`PNAME` varchar(50) DEFAULT NULL,
`COLOR` varchar(20) DEFAULT NULL,
`WEIGHT` int DEFAULT NULL,
`CITY` varchar(50) DEFAULT NULL,
PRIMARY KEY (`PID`)
);
INSERT INTO `p` VALUES ('P1','Nut','Red',12,'London'),('P2','Bolt','Green',17,'Paris'),
('P3','Screw','Blue',17,'Rome'),('P4','Screw','Red',14,'London'),('P5','Cam','Blue',12,'Paris'),
('P6','Cog','Red',19,'London');

3.
CREATE TABLE `j` (
`JID` varchar(10) NOT NULL,
`JNAME` varchar(50) DEFAULT NULL,
`CITY` varchar(50) DEFAULT NULL,
PRIMARY KEY (`JID`)
);
INSERT INTO `j` VALUES ('J1','Sorter','Paris'),('J2','Display','Rome'),('J3','OCR','Athens'),
('J4','Console','Athens'),('J5','RAID','London'),('J6','EDS','Oslo'),('J7','Tape','London');
4.
CREATE TABLE `spj` (
`SID` varchar(10) NOT NULL,
`PID` varchar(10) NOT NULL,
`JID` varchar(10) NOT NULL,
`QTY` int DEFAULT NULL,
PRIMARY KEY (`SID`,`PID`,`JID`),
KEY `P#` (`PID`),
KEY `J#` (`JID`),
CONSTRAINT `spj_ibfk_1` FOREIGN KEY (`SID`) REFERENCES `s` (`SID`),
CONSTRAINT `spj_ibfk_2` FOREIGN KEY (`PID`) REFERENCES `p` (`PID`),
CONSTRAINT `spj_ibfk_3` FOREIGN KEY (`JID`) REFERENCES `j` (`JID`)
);
INSERT INTO `spj` VALUES ('S1','P1','J1',200),('S1','P1','J4',700),('S2','P3','J1',400),
('S2','P3','J2',200),('S2','P3','J3',200),('S2','P3','J4',500),('S2','P3','J5',600),
('S2','P3','J6',400),('S2','P3','J7',800),('S2','P5','J2',100),('S3','P3','J1',200),
('S3','P4','J2',500),('S4','P6','J3',300),('S4','P6','J7',300),('S5','P1','J4',100),
('S5','P2','J2',200),('S5','P2','J4',100),('S5','P3','J4',200),('S5','P4','J4',800),
('S5','P5','J4',400),('S5','P5','J5',500),('S5','P5','J7',100),('S5','P6','J2',200),
('S5','P6','J4',500);

You might also like