File notes/code/sql/HW_Storm.sql changed (mode: 100644) (index 64b7f38..344e10b) |
... |
... |
INSERT INTO STORM |
36 |
36 |
-- The error message returned is |
-- The error message returned is |
37 |
37 |
-- ERROR 1292 (22007) at line 34: Incorrect date value: '2017-17-08' for column `HW_STORM`.`STORM`.`Creation` at row 1 |
-- ERROR 1292 (22007) at line 34: Incorrect date value: '2017-17-08' for column `HW_STORM`.`STORM`.`Creation` at row 1 |
38 |
38 |
|
|
39 |
|
INSERT INTO STORM |
|
40 |
|
VALUES ('Dummy2', 'Hurricane', 120, DATE '2017-17-08'); |
|
|
39 |
|
-- In the following, we explicitely use 'DATE', and since the date is incorrect, nothing gets inserted. |
|
40 |
|
--INSERT INTO STORM |
|
41 |
|
-- VALUES ('Dummy2', 'Hurricane', 120, DATE '2017-17-08'); |
|
42 |
|
-- ERROR 1525 (HY000) at line 40: Incorrect DATE value: '2017-17-08' |
|
43 |
|
|
41 |
44 |
|
|
42 |
45 |
-- The next one sets NULL for DATE. |
-- The next one sets NULL for DATE. |
43 |
46 |
INSERT INTO STORM |
INSERT INTO STORM |
File notes/code/sql/HW_Work.sql changed (mode: 100644) (index 040dc20..59685f8) |
... |
... |
INSERT INTO EBOOK |
82 |
82 |
Query OK, 1 row affected (0.003 sec) |
Query OK, 1 row affected (0.003 sec) |
83 |
83 |
So, "Successful insertion". |
So, "Successful insertion". |
84 |
84 |
*/ |
*/ |
85 |
|
INSERT INTO AUTHOR |
|
86 |
|
VALUES ("Mary B.", "mb@fai.fr", NULL); |
|
87 |
|
|
|
88 |
|
|
|
|
85 |
|
-- The following statement raises an error. |
|
86 |
|
--INSERT INTO AUTHOR |
|
87 |
|
-- VALUES ("Mary B.", "mb@fai.fr", NULL); |
89 |
88 |
/* |
/* |
90 |
89 |
ERROR 1136 (21S01): Column count doesn't match value count at row 1 |
ERROR 1136 (21S01): Column count doesn't match value count at row 1 |
91 |
90 |
So, "Other kind of error". |
So, "Other kind of error". |
92 |
91 |
*/ |
*/ |
93 |
|
INSERT INTO WORK |
|
94 |
|
VALUES ("My Life", "Claude A."); |
|
95 |
|
|
|
96 |
|
|
|
|
92 |
|
-- The following statement raises an error. |
|
93 |
|
--INSERT INTO WORK |
|
94 |
|
-- VALUES ("My Life", "Claude A."); |
97 |
95 |
/* |
/* |
98 |
96 |
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails |
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails |
99 |
97 |
(`HW_EXAM_1`.`WORK`, CONSTRAINT `WORK_ibfk_1` FOREIGN KEY (`Author`) REFERENCES `AUTHOR` (`Name`) |
(`HW_EXAM_1`.`WORK`, CONSTRAINT `WORK_ibfk_1` FOREIGN KEY (`Author`) REFERENCES `AUTHOR` (`Name`) |
|
... |
... |
INSERT INTO BOOK |
108 |
106 |
Query OK, 1 row affected (0.000 sec) |
Query OK, 1 row affected (0.000 sec) |
109 |
107 |
So, "Successful insertion". |
So, "Successful insertion". |
110 |
108 |
*/ |
*/ |
111 |
|
INSERT INTO AUTHOR |
|
112 |
|
VALUES ("Virginia W.", "alt@isp.net"); |
|
|
109 |
|
|
|
110 |
|
-- The following statement raises an error. |
|
111 |
|
-- INSERT INTO AUTHOR |
|
112 |
|
-- VALUES ("Virginia W.", "alt@isp.net"); |
113 |
113 |
|
|
114 |
114 |
|
|
115 |
115 |
/* |
/* |
|
... |
... |
WHERE |
153 |
153 |
but other rows have been changed as well. |
but other rows have been changed as well. |
154 |
154 |
This changed W.1, B.1, E.1. |
This changed W.1, B.1, E.1. |
155 |
155 |
*/ |
*/ |
156 |
|
DELETE FROM WORK; |
|
157 |
|
|
|
158 |
|
|
|
|
156 |
|
-- The following statement raises an error. |
|
157 |
|
-- DELETE FROM WORK; |
159 |
158 |
/* |
/* |
160 |
159 |
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails |
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails |
161 |
160 |
(`HW_EXAM_1`.`BOOK`, CONSTRAINT `BOOK_ibfk_1` FOREIGN KEY (`Work`) REFERENCES `WORK` (`Title`) ON UPDATE CASCADE) |
(`HW_EXAM_1`.`BOOK`, CONSTRAINT `BOOK_ibfk_1` FOREIGN KEY (`Work`) REFERENCES `WORK` (`Title`) ON UPDATE CASCADE) |
162 |
161 |
Does not change any row. |
Does not change any row. |
163 |
162 |
*/ |
*/ |
164 |
|
DELETE FROM AUTHOR |
|
165 |
|
WHERE Name = "Virginia W."; |
|
|
163 |
|
-- The following statement raises an error. |
|
164 |
|
-- DELETE FROM AUTHOR |
|
165 |
|
-- WHERE Name = "Virginia W."; |
166 |
166 |
|
|
167 |
167 |
|
|
168 |
168 |
/* |
/* |
|
... |
... |
WHERE |
262 |
262 |
Write a command that updates the title of all the pieces of work written by the author whose name is “Virginia W. to”BANNED". |
Write a command that updates the title of all the pieces of work written by the author whose name is “Virginia W. to”BANNED". |
263 |
263 |
Is there any reason for this command to be rejected by the system? If yes, explain which one. |
Is there any reason for this command to be rejected by the system? If yes, explain which one. |
264 |
264 |
*/ |
*/ |
|
265 |
|
-- The following statement raises an error. |
|
266 |
|
/* |
265 |
267 |
UPDATE |
UPDATE |
266 |
268 |
WORK |
WORK |
267 |
269 |
SET |
SET |
268 |
270 |
Title = "BANNED" |
Title = "BANNED" |
269 |
271 |
WHERE |
WHERE |
270 |
272 |
Author = "Virginia W."; |
Author = "Virginia W."; |
271 |
|
|
|
|
273 |
|
*/ |
272 |
274 |
|
|
273 |
275 |
/* |
/* |
274 |
|
Does not give an error with the that we currently have. |
|
275 |
|
However, since "Title" is the primary key in the WORK table, if Virginia W. had authored two pieces of work or more, |
|
276 |
|
then this command would give an error. |
|
|
276 |
|
Gives an error, since "Title" is the primary key in the WORK table, and Virginia W. has authored two pieces of work or more, |
|
277 |
|
they are both given the title "BANNED", which violates the unicity of value in primary keys. |
277 |
278 |
*/ |
*/ |
278 |
279 |
-- Write one or multiple commands that would delete the work whose title is “My Life”, as well as all of the books and ebooks versions of it. |
-- Write one or multiple commands that would delete the work whose title is “My Life”, as well as all of the books and ebooks versions of it. |
279 |
|
DELETE FROM WORK |
|
280 |
|
WHERE Title = "My Life"; |
|
|
280 |
|
-- The following statement raises an error. |
|
281 |
|
--DELETE FROM WORK |
|
282 |
|
--WHERE Title = "My Life"; |
281 |
283 |
|
|
282 |
284 |
|
|
283 |
285 |
/* |
/* |