 USE [master];
+GO
 IF EXISTS(SELECT * from sys.databases where name = 'DBU201414800')
 DROP DATABASE [DBU201414800];
+GO
 CREATE DATABASE [DBU201414800];
+GO
 USE [DBU201414800];
+GO
 
 IF (EXISTS (SELECT * FROM sys.schemas WHERE name = 'SPJ414800'))
 DROP SCHEMA [SPJ414800];
+GO
 EXEC ('CREATE SCHEMA [SPJ414800]');
-ALTER USER [dbo] WITH DEFAULT_SCHEMA [SPJ414800];
-
-CREATE TABLE `S` (
-	`SNO` VARCHAR(5) PRIMARY KEY,
-    `SNAME` VARCHAR(30) NOT NULL,
-    `STATUS` INT,
-    `CITY` VARCHAR(30)
-);
-
-CREATE TABLE `P` (
-	`PNO` VARCHAR(5) PRIMARY KEY,
-    `PNAME` VARCHAR(30) NOT NULL,
-    `COLOR` VARCHAR(10),
-    `WEIGHT` INT DEFAULT 10
-);
-
-CREATE TABLE `J` (
-	`JNO` VARCHAR(5) PRIMARY KEY,
-    `JNAME` VARCHAR(30) NOT NULL,
-    `CITY` VARCHAR(30)
-);
-
-CREATE TABLE `SPJ` (
-	`SNO` VARCHAR(5),
-    `PNO` VARCHAR(5),
-    `JNO` VARCHAR(5),
-    `QTY` INT CHECK(`QTY` >= 1 AND `QTY` <= 10000),
-    PRIMARY KEY(`SNO`, `PNO`, `JNO`),
-    FOREIGN KEY (`SNO`)
-		REFERENCES `S`(`SNO`)
+GO
+-- ALTER USER [dbo] WITH DEFAULT_SCHEMA = [SPJ414800];
+-- GO
+
+CREATE TABLE [SPJ414800].[S] (
+	[SNO] VARCHAR(5) PRIMARY KEY,
+    [SNAME] VARCHAR(30) NOT NULL,
+    [STATUS] INT,
+    [CITY] VARCHAR(30)
+);
+
+CREATE TABLE [SPJ414800].[P] (
+	[PNO] VARCHAR(5) PRIMARY KEY,
+    [PNAME] VARCHAR(30) NOT NULL,
+    [COLOR] VARCHAR(10),
+    [WEIGHT] INT DEFAULT 10
+);
+
+CREATE TABLE [SPJ414800].[J] (
+	[JNO] VARCHAR(5) PRIMARY KEY,
+    [JNAME] VARCHAR(30) NOT NULL,
+    [CITY] VARCHAR(30)
+);
+
+CREATE TABLE [SPJ414800].[SPJ] (
+	[SNO] VARCHAR(5),
+    [PNO] VARCHAR(5),
+    [JNO] VARCHAR(5),
+    [QTY] INT CHECK([QTY] >= 1 AND [QTY] <= 10000),
+    PRIMARY KEY([SNO], [PNO], [JNO]),
+    FOREIGN KEY ([SNO])
+		REFERENCES [SPJ414800].[S]([SNO])
         ON DELETE CASCADE
         ON UPDATE CASCADE,
-    FOREIGN KEY (`PNO`)
-		REFERENCES `P`(`PNO`)
+    FOREIGN KEY ([PNO])
+		REFERENCES [SPJ414800].[P]([PNO])
         ON DELETE CASCADE
         ON UPDATE CASCADE,
-	FOREIGN KEY (`JNO`)
-		REFERENCES `J`(`JNO`)
+	FOREIGN KEY ([JNO])
+		REFERENCES [SPJ414800].[J]([JNO])
         ON DELETE CASCADE
         ON UPDATE CASCADE
 );
 
-CREATE TABLE `BIG_SPJ` LIKE `SPJ`;
-
-ALTER TABLE `P` ADD COLUMN `PRICE` FLOAT;
-ALTER TABLE `J` ADD COLUMN `JSTART` DATE NOT NULL;
-ALTER TABLE `J` ADD COLUMN `JEND` DATE;
-ALTER TABLE `J` ADD CHECK(`JEND` > `JSTART`);
-
-INSERT INTO `S` VALUES('S1', '精益', 20, '天津');
-INSERT INTO `S` VALUES('S2', '盛锡', 10, '北京');
-INSERT INTO `S` VALUES('S3', '东方红', 30, '北京');
-INSERT INTO `S` VALUES('S4', '丰泰盛', 20, '天津');
-INSERT INTO `S` VALUES('S5', '为民', 30, '上海');
-
-INSERT INTO `P` VALUES('P1', '螺母', '红', 12, FLOOR(2 + (RAND() * 3)));
-INSERT INTO `P` VALUES('P2', '螺栓', '绿', 17, FLOOR(3 + (RAND() * 3)));
-INSERT INTO `P` VALUES('P3', '螺丝刀', '蓝', 14, FLOOR(5 + (RAND() * 3)));
-INSERT INTO `P` VALUES('P4', '螺丝刀', '红', 14, FLOOR(6 + (RAND() * 3)));
-INSERT INTO `P` VALUES('P5', '凸轮', '蓝', 40, FLOOR(7 + (RAND() * 3)));
-INSERT INTO `P` VALUES('P6', '齿轮', '红', 30, FLOOR(8 + (RAND() * 3)));
-
-INSERT INTO `J` VALUES('J1', '三建', '北京', DATE(DATE_SUB(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)), DATE(DATE_ADD(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)));
-INSERT INTO `J` VALUES('J2', '一汽', '长春', DATE(DATE_SUB(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)), DATE(DATE_ADD(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)));
-INSERT INTO `J` VALUES('J3', '弹簧厂', '天津', DATE(DATE_SUB(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)), DATE(DATE_ADD(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)));
-INSERT INTO `J` VALUES('J4', '造船厂', '天津', DATE(DATE_SUB(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)), DATE(DATE_ADD(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)));
-INSERT INTO `J` VALUES('J5', '机车厂', '唐山', DATE(DATE_SUB(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)), DATE(DATE_ADD(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)));
-INSERT INTO `J` VALUES('J6', '无线电厂', '常州', DATE(DATE_SUB(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)), DATE(DATE_ADD(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)));
-INSERT INTO `J` VALUES('J7', '半导体厂', '南京', DATE(DATE_SUB(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)), DATE(DATE_ADD(NOW(), INTERVAL FLOOR(RAND() * 14) DAY)));
-
-INSERT INTO `SPJ` VALUES('S1', 'P1', 'J1', 200);
-INSERT INTO `SPJ` VALUES('S1', 'P1', 'J3', 100);
-INSERT INTO `SPJ` VALUES('S1', 'P1', 'J4', 700);
-INSERT INTO `SPJ` VALUES('S1', 'P2', 'J2', 100);
-INSERT INTO `SPJ` VALUES('S2', 'P3', 'J1', 400);
-INSERT INTO `SPJ` VALUES('S2', 'P3', 'J2', 200);
-INSERT INTO `SPJ` VALUES('S2', 'P3', 'J4', 500);
-INSERT INTO `SPJ` VALUES('S2', 'P3', 'J5', 400);
-INSERT INTO `SPJ` VALUES('S2', 'P5', 'J1', 400);
-INSERT INTO `SPJ` VALUES('S2', 'P5', 'J2', 100);
-INSERT INTO `SPJ` VALUES('S3', 'P1', 'J1', 200);
-INSERT INTO `SPJ` VALUES('S3', 'P3', 'J1', 200);
-INSERT INTO `SPJ` VALUES('S4', 'P5', 'J1', 100);
-INSERT INTO `SPJ` VALUES('S4', 'P6', 'J3', 300);
-INSERT INTO `SPJ` VALUES('S4', 'P6', 'J4', 200);
-INSERT INTO `SPJ` VALUES('S5', 'P2', 'J4', 100);
-INSERT INTO `SPJ` VALUES('S5', 'P3', 'J1', 200);
-INSERT INTO `SPJ` VALUES('S5', 'P6', 'J2', 200);
-INSERT INTO `SPJ` VALUES('S5', 'P6', 'J4', 500);
-
-INSERT INTO `BIG_SPJ`
+CREATE TABLE [SPJ414800].[BIG_SPJ] (
+	[SNO] VARCHAR(5),
+    [PNO] VARCHAR(5),
+    [JNO] VARCHAR(5),
+    [QTY] INT CHECK([QTY] >= 1 AND [QTY] <= 10000),
+    PRIMARY KEY([SNO], [PNO], [JNO]),
+    FOREIGN KEY ([SNO])
+		REFERENCES [SPJ414800].[S]([SNO])
+        ON DELETE CASCADE
+        ON UPDATE CASCADE,
+    FOREIGN KEY ([PNO])
+		REFERENCES [SPJ414800].[P]([PNO])
+        ON DELETE CASCADE
+        ON UPDATE CASCADE,
+	FOREIGN KEY ([JNO])
+		REFERENCES [SPJ414800].[J]([JNO])
+        ON DELETE CASCADE
+        ON UPDATE CASCADE
+);
+
+ALTER TABLE [SPJ414800].[P] ADD [PRICE] FLOAT;
+ALTER TABLE [SPJ414800].[J] ADD [JSTART] DATE NOT NULL;
+ALTER TABLE [SPJ414800].[J] ADD [JEND] DATE;
+ALTER TABLE [SPJ414800].[J] ADD CHECK([JEND] > [JSTART]);
+
+INSERT INTO [SPJ414800].[S] VALUES('S1', '', 20, '');
+INSERT INTO [SPJ414800].[S] VALUES('S2', 'ʢ', 10, '');
+INSERT INTO [SPJ414800].[S] VALUES('S3', '', 30, '');
+INSERT INTO [SPJ414800].[S] VALUES('S4', '̩ʢ', 20, '');
+INSERT INTO [SPJ414800].[S] VALUES('S5', 'Ϊ', 30, 'Ϻ');
+
+INSERT INTO [SPJ414800].[P] VALUES('P1', 'ĸ', '', 12, FLOOR(2 + (RAND() * 3)));
+INSERT INTO [SPJ414800].[P] VALUES('P2', '˨', '', 17, FLOOR(3 + (RAND() * 3)));
+INSERT INTO [SPJ414800].[P] VALUES('P3', '˿', '', 14, FLOOR(5 + (RAND() * 3)));
+INSERT INTO [SPJ414800].[P] VALUES('P4', '˿', '', 14, FLOOR(6 + (RAND() * 3)));
+INSERT INTO [SPJ414800].[P] VALUES('P5', '͹', '', 40, FLOOR(7 + (RAND() * 3)));
+INSERT INTO [SPJ414800].[P] VALUES('P6', '', '', 30, FLOOR(8 + (RAND() * 3)));
+
+INSERT INTO [SPJ414800].[J] VALUES('J1', '', '', DATEADD(DAY, -ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)), DATEADD(DAY, ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)));
+INSERT INTO [SPJ414800].[J] VALUES('J2', 'һ', '', DATEADD(DAY, -ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)), DATEADD(DAY, ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)));
+INSERT INTO [SPJ414800].[J] VALUES('J3', 'ɳ', '', DATEADD(DAY, -ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)), DATEADD(DAY, ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)));
+INSERT INTO [SPJ414800].[J] VALUES('J4', '촬', '', DATEADD(DAY, -ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)), DATEADD(DAY, ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)));
+INSERT INTO [SPJ414800].[J] VALUES('J5', '', 'ɽ', DATEADD(DAY, -ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)), DATEADD(DAY, ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)));
+INSERT INTO [SPJ414800].[J] VALUES('J6', 'ߵ糧', '', DATEADD(DAY, -ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)), DATEADD(DAY, ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)));
+INSERT INTO [SPJ414800].[J] VALUES('J7', '뵼峧', 'Ͼ', DATEADD(DAY, -ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)), DATEADD(DAY, ABS(CHECKSUM(NEWID()) % 14), CAST(GETDATE()AS DATE)));
+
+INSERT INTO [SPJ414800].[SPJ] VALUES('S1', 'P1', 'J1', 200);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S1', 'P1', 'J3', 100);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S1', 'P1', 'J4', 700);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S1', 'P2', 'J2', 100);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S2', 'P3', 'J1', 400);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S2', 'P3', 'J2', 200);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S2', 'P3', 'J4', 500);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S2', 'P3', 'J5', 400);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S2', 'P5', 'J1', 400);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S2', 'P5', 'J2', 100);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S3', 'P1', 'J1', 200);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S3', 'P3', 'J1', 200);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S4', 'P5', 'J1', 100);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S4', 'P6', 'J3', 300);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S4', 'P6', 'J4', 200);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S5', 'P2', 'J4', 100);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S5', 'P3', 'J1', 200);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S5', 'P6', 'J2', 200);
+INSERT INTO [SPJ414800].[SPJ] VALUES('S5', 'P6', 'J4', 500);
+
+INSERT INTO [SPJ414800].[BIG_SPJ]
 SELECT *
-FROM `SPJ`
-WHERE `SPJ`.`QTY` > 400;
+FROM [SPJ414800].[SPJ]
+WHERE [SPJ414800].[SPJ].[QTY] > 400;
 
 /* integrity violation insertion */
-INSERT INTO `S` VALUES('S1', '华科重工', 30, '武汉');	/* error: primary key */
-INSERT INTO `S` VALUES(NULL, '华科重工', 30, '武汉');	/* error: entity integrity */
-INSERT INTO `SPJ` VALUES('S233', 'P233', 'J233', 233);	/* error: referential integrity */
-INSERT INTO `S` VALUES('S6', NULL, 30, '武汉');			/* error: user-defined integrity */
--- INSERT INTO `SPJ` VALUES('S1', 'P1', 'J7', 23333);		/* error: user-defined integrity */
--- INSERT INTO `J` VALUES('J8', '阿姆斯特朗对撞超级计算机中心', '武汉', '2017-07-01', '2016-12-25');	/* error: user-defined integrity */
+INSERT INTO [SPJ414800].[S] VALUES('S1', 'ع', 30, '人');	/* error: primary key */
+INSERT INTO [SPJ414800].[S] VALUES(NULL, 'ع', 30, '人');	/* error: entity integrity */
+INSERT INTO [SPJ414800].[SPJ] VALUES('S233', 'P233', 'J233', 233);	/* error: referential integrity */
+INSERT INTO [SPJ414800].[S] VALUES('S6', NULL, 30, '人');			/* error: user-defined integrity */
+INSERT INTO [SPJ414800].[SPJ] VALUES('S1', 'P1', 'J7', 23333);		/* error: user-defined integrity */
+INSERT INTO [SPJ414800].[J] VALUES('J8', 'ķ˹ʶײ', '人', '2017-07-01', '2016-12-25');	/* error: user-defined integrity */
 
 /*
-SELECT * FROM `S`;
-SELECT * FROM `P`;
-SELECT * FROM `J`;
-SELECT * FROM `SPJ`;
-SELECT * FROM `BIG_SPJ`;
+SELECT * FROM [SPJ414800].[S];
+SELECT * FROM [SPJ414800].[P];
+SELECT * FROM [SPJ414800].[J];
+SELECT * FROM [SPJ414800].[SPJ];
+SELECT * FROM [SPJ414800].[BIG_SPJ];
 */
 
 /* 2-6 */
 
-SELECT DISTINCT `SNO`
-FROM `SPJ`
-WHERE `JNO` = 'J1';
-
-SELECT DISTINCT `SNO`
-FROM `SPJ`
-WHERE `PNO` = 'P1' AND `JNO` = 'J1';
-
-SELECT DISTINCT `SNO`
-FROM `P`, `SPJ`
-WHERE `P`.`PNO` = `SPJ`.`PNO`
-	AND `JNO` = 'J1'
-    AND `COLOR` = '红';
-
-SELECT  DISTINCT `JNO`
-FROM `SPJ`
-WHERE `JNO` NOT IN (
-	SELECT `JNO`
-    FROM `S`, `P`, `SPJ`
-    WHERE `S`.`SNO` = `SPJ`.`SNO`
-		AND `P`.`PNO` = `SPJ`.`PNO`
-        AND `CITY` ='天津'
-        AND `COLOR` = '红'
-);
-
-SELECT DISTINCT `JNO`
-FROM `SPJ` `SPJX`
+SELECT DISTINCT [SNO]
+FROM [SPJ414800].[SPJ]
+WHERE [JNO] = 'J1';
+
+SELECT DISTINCT [SNO]
+FROM [SPJ414800].[SPJ]
+WHERE [PNO] = 'P1' AND [JNO] = 'J1';
+
+SELECT DISTINCT [SNO]
+FROM [SPJ414800].[P], [SPJ414800].[SPJ]
+WHERE [SPJ414800].[P].[PNO] = [SPJ414800].[SPJ].[PNO]
+	AND [JNO] = 'J1'
+    AND [COLOR] = '';
+
+SELECT  DISTINCT [JNO]
+FROM [SPJ414800].[SPJ]
+WHERE [JNO] NOT IN (
+	SELECT [JNO]
+    FROM [SPJ414800].[S], [SPJ414800].[P], [SPJ414800].[SPJ]
+    WHERE [SPJ414800].[S].[SNO] = [SPJ414800].[SPJ].[SNO]
+		AND [SPJ414800].[P].[PNO] = [SPJ414800].[SPJ].[PNO]
+        AND [CITY] =''
+        AND [COLOR] = ''
+);
+
+SELECT DISTINCT [JNO]
+FROM [SPJ414800].[SPJ] [SPJX]
 WHERE NOT EXISTS (
 	SELECT *
-    FROM `SPJ` `SPJY`
-    WHERE `SPJY`.`SNO` = 'S1'
+    FROM [SPJ414800].[SPJ] [SPJY]
+    WHERE [SPJY].[SNO] = 'S1'
 		AND NOT EXISTS (
 			SELECT *
-			FROM `SPJ` `SPJZ`
-			WHERE `SPJX`.`JNO` = `SPJZ`.`JNO`
-				AND `SPJY`.`PNO` = `SPJZ`.`PNO`
+			FROM [SPJ414800].[SPJ] [SPJZ]
+			WHERE [SPJX].[JNO] = [SPJZ].[JNO]
+				AND [SPJY].[PNO] = [SPJZ].[PNO]
 		)
 );
 


/* 3-5 part1 */

SELECT `SNAME`, `CITY`
FROM `S`;

SELECT `PNAME`, `COLOR`, `WEIGHT`
FROM `P`;

SELECT DISTINCT `JNO`
FROM `SPJ`
WHERE `SNO` = 'S1';

SELECT `PNAME`, `QTY`
FROM `P`, `SPJ`
WHERE `P`.`PNO` = `SPJ`.`PNO`
	AND `JNO` = 'J2';

SELECT DISTINCT `PNO`
FROM `S`, `SPJ`
WHERE `S`.`SNO` = `SPJ`.`SNO`
	AND `CITY` = '上海';

SELECT DISTINCT `JNAME`
FROM `S`, `J`, `SPJ`
WHERE `S`.`SNO` = `SPJ`.`SNO`
	AND `J`.`JNO` = `SPJ`.`JNO`
    AND `S`.`CITY` = '上海';

SELECT DISTINCT `JNO`
FROM `SPJ`
WHERE `JNO` NOT IN (
	SELECT DISTINCT `JNO`
    FROM `S`, `SPJ`
    WHERE `S`.`SNO` = `SPJ`.`SNO`
		AND `CITY`= '天津'
);

/* 3-5 part1 */

/* additional SQL */

SELECT DISTINCT `P`.`PNO`, `PNAME`, `JNAME`
FROM `P`, `J`, `SPJ`
WHERE `P`.`PNO` = `SPJ`.`PNO`
	AND `J`.`JNO` = `SPJ`.`JNO`
    AND `JNAME` LIKE '%厂'
ORDER BY `JNAME`, `PNO`, `PNAME`;

SELECT DISTINCT `JNO`, SUM(`PRICE`) AS `JPRICE`
FROM `P`, `SPJ`
WHERE `P`.`PNO` = `SPJ`.`PNO`
GROUP BY `JNO`
ORDER BY `JPRICE` DESC;

SELECT DISTINCT `SNO`, SUM(`QTY`) AS `SQTY`
FROM `SPJ`
GROUP BY `SNO`;

SELECT DISTINCT `JNO`, DATEDIFF(`JEND`, `JSTART`) AS `JDAY`
FROM `J`
WHERE DATEDIFF(`JEND`, `JSTART`) <= 365;

SELECT DISTINCT `JNO`
FROM `SPJ`
WHERE `JNO` NOT IN (
	SELECT `J`.`JNO`
    FROM `S`, `J`, `SPJ`
    WHERE `S`.`SNO` = `SPJ`.`SNO`
		AND `J`.`JNO` = `SPJ`.`JNO`
        AND `S`.`CITY` = `J`.`CITY`
);

/* additional SQL */


/* 3-9 */

/* multiple-table view: can't get updated */
CREATE VIEW [SANJIAN_SPJ]([SNO], [PNO], [QTY])
AS
SELECT [SNO], [PNO], [QTY]
FROM [SPJ414800].[J], [SPJ414800].[SPJ]
WHERE [SPJ414800].[J].[JNO] = [SPJ414800].[SPJ].[JNO]
	AND [JNAME] = ''
WITH CHECK OPTION;
GO

SELECT [PNO], [QTY] FROM [SANJIAN_SPJ];
SELECT * FROM [SANJIAN_SPJ] WHERE [SNO] = 'S1';
GO

CREATE VIEW [TIANJING_S]
AS
SELECT [SNO], [SNAME], [STATUS]
FROM [SPJ414800].[S]
WHERE [CITY] = '';
-- WHERE [CITY] = ''
-- WITH CHECK OPTION;
GO

INSERT INTO [TIANJING_S] VALUES('S23', 'ع', 30);
SELECT * FROM [SPJ414800].[S];

/* 3-9 */


/* 3-5 part2 */

UPDATE [SPJ414800].[P]
SET [COLOR] = ''
WHERE [COLOR] = '';
SELECT * FROM [SPJ414800].[P];

UPDATE [SPJ414800].[SPJ]
SET [SNO] = 'S3'
WHERE [SNO] = 'S5'
	AND [PNO] = 'P6'
	AND [JNO] = 'J4';
SELECT * FROM [SPJ414800].[SPJ];

INSERT INTO [SPJ414800].[SPJ] VALUES('S2', 'P4', 'J6', 200);
SELECT * FROM [SPJ414800].[SPJ];

DELETE FROM [SPJ414800].[S] WHERE [SNO] = 'S2';		/* cascade */
SELECT * FROM [SPJ414800].[S];
SELECT * FROM [SPJ414800].[SPJ];

/* 3-5 part2 */