Commit e6594ae2 authored by mi's avatar mi

Simplifying multipe «drop table» statements

parent 4addeedb
DROP TABLE IF EXISTS Para; DROP TABLE IF EXISTS Para, `To`, Memo ;
DROP TABLE IF EXISTS `To`;
DROP TABLE IF EXISTS Memo;
CREATE TABLE Memo ( CREATE TABLE Memo (
id INT PRIMARY KEY, id INT PRIMARY KEY,
...@@ -23,4 +21,4 @@ CREATE TABLE Para ( ...@@ -23,4 +21,4 @@ CREATE TABLE Para (
memo INT NOT NULL, memo INT NOT NULL,
PRIMARY KEY (item, memo), PRIMARY KEY (item, memo),
FOREIGN KEY (memo) REFERENCES Memo(id) FOREIGN KEY (memo) REFERENCES Memo(id)
); );
\ No newline at end of file
DROP TABLE IF EXISTS Student; DROP TABLE IF EXISTS Student, StudyCourse;
DROP TABLE IF EXISTS StudyCourse;
CREATE TABLE StudyCourse ( CREATE TABLE StudyCourse (
id INTEGER NOT NULL PRIMARY KEY id INTEGER NOT NULL PRIMARY KEY
......
DROP TABLE IF EXISTS Student; DROP TABLE IF EXISTS Student, StudyCourse;
DROP TABLE IF EXISTS StudyCourse;
CREATE TABLE StudyCourse ( CREATE TABLE StudyCourse (
id INTEGER NOT NULL PRIMARY KEY id INTEGER NOT NULL PRIMARY KEY
......
DROP TABLE IF EXISTS LanguageScript; DROP TABLE IF EXISTS LanguageScript, Script, Language;
DROP TABLE IF EXISTS Script;
DROP TABLE IF EXISTS Language;
CREATE TABLE Language ( CREATE TABLE Language (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
......
DROP TABLE IF EXISTS Translation; DROP TABLE IF EXISTS Translation, Noun, Language;
DROP TABLE IF EXISTS Noun;
DROP TABLE IF EXISTS Language;
CREATE TABLE Language ( CREATE TABLE Language (
id INTEGER AUTO_INCREMENT PRIMARY KEY, id INTEGER AUTO_INCREMENT PRIMARY KEY,
......
DROP TABLE IF EXISTS ActorMovie; DROP TABLE IF EXISTS ActorMovie, Movie, Person;
DROP TABLE IF EXISTS Movie;
DROP TABLE IF EXISTS Person;
CREATE TABLE Person ( CREATE TABLE Person (
id CHAR(255) PRIMARY KEY id CHAR(255) PRIMARY KEY
......
DROP TABLE IF EXISTS Employee; DROP TABLE IF EXISTS Employee, Department;
DROP TABLE IF EXISTS Department;
CREATE TABLE Department( CREATE TABLE Department(
......
DROP TABLE IF EXISTS Employee; DROP TABLE IF EXISTS Employee, Department;
DROP TABLE IF EXISTS Department;
CREATE TABLE Department( CREATE TABLE Department(
......
show tables;
show create TABLE FsObject;
DROP TABLE IF EXISTS FsObject; DROP TABLE IF EXISTS FsObject;
CREATE TABLE FsObject ( CREATE TABLE FsObject (
/* TODO: Implement me!*/ /* TODO: Implement me!*/
); );
\ No newline at end of file
DROP TABLE IF EXISTS Student; DROP TABLE IF EXISTS Student;
CREATE TABLE Student ( CREATE TABLE Student (
......
show tables;
show create TABLE FsObject;
DROP TABLE IF EXISTS FsObject; DROP TABLE IF EXISTS FsObject;
CREATE TABLE FsObject ( CREATE TABLE FsObject (
...@@ -41,4 +38,4 @@ INSERT INTO FsObject VALUES( ...@@ -41,4 +38,4 @@ INSERT INTO FsObject VALUES(
"Symlink_A_to_test.txt", /* File in "Dir_A" */ "Symlink_A_to_test.txt", /* File in "Dir_A" */
100, /* Directory "A" */ 100, /* Directory "A" */
2, /* Typ file */ 2, /* Typ file */
null); /* No symlink */ null); /* No symlink */
\ No newline at end of file
DROP TABLE IF EXISTS Student; DROP TABLE IF EXISTS Student;
CREATE TABLE Student ( CREATE TABLE Student (
......
DROP TABLE IF EXISTS Competition; DROP TABLE IF EXISTS Competition, Athlete;
DROP TABLE IF EXISTS Athlete;
CREATE TABLE Athlete ( CREATE TABLE Athlete (
id INT NOT NULL PRIMARY KEY id INT NOT NULL PRIMARY KEY
...@@ -27,4 +26,4 @@ INSERT INTO Competition VALUES(4, 4, 10.02, FALSE); /* John Hooker */ ...@@ -27,4 +26,4 @@ INSERT INTO Competition VALUES(4, 4, 10.02, FALSE); /* John Hooker */
INSERT INTO Competition VALUES(5, 5, 10.84, FALSE); /* Brad Duncan */ INSERT INTO Competition VALUES(5, 5, 10.84, FALSE); /* Brad Duncan */
INSERT INTO Competition VALUES(6, 2, 10.02, FALSE); /* Tim Culver */ INSERT INTO Competition VALUES(6, 2, 10.02, FALSE); /* Tim Culver */
INSERT INTO Competition VALUES(7, 3, 10.49, FALSE); /* Sid Gascoine */ INSERT INTO Competition VALUES(7, 3, 10.49, FALSE); /* Sid Gascoine */
INSERT INTO Competition VALUES(8, 2, 9.35, TRUE); /* Tim Culver */ INSERT INTO Competition VALUES(8, 2, 9.35, TRUE); /* Tim Culver */
\ No newline at end of file
DROP TABLE IF EXISTS Competition; DROP TABLE IF EXISTS Competition, Athlete;
DROP TABLE IF EXISTS Athlete;
CREATE TABLE Athlete ( CREATE TABLE Athlete (
id INT NOT NULL PRIMARY KEY id INT NOT NULL PRIMARY KEY
...@@ -41,4 +40,4 @@ FROM Competition, Athlete ...@@ -41,4 +40,4 @@ FROM Competition, Athlete
WHERE Competition.athlete = Athlete.id WHERE Competition.athlete = Athlete.id
AND NOT(badStart) AND NOT(badStart)
GROUP BY Athlete.id GROUP BY Athlete.id
ORDER BY time, fullName; ORDER BY time, fullName;
\ No newline at end of file
DROP TABLE IF EXISTS Para; DROP TABLE IF EXISTS Para, Section;
DROP TABLE IF EXISTS Section;
-- TODO -- TODO
-- Read the exercise's documentation and add your schema here. You may -- Read the exercise's documentation and add your schema here. You may
...@@ -42,4 +41,4 @@ SELECT * FROM Section; ...@@ -42,4 +41,4 @@ SELECT * FROM Section;
SELECT * FROM Para; SELECT * FROM Para;
\ No newline at end of file
DROP TABLE IF EXISTS Para; DROP TABLE IF EXISTS Para, Section;
DROP TABLE IF EXISTS Section;
CREATE TABLE Section ( CREATE TABLE Section (
id VARCHAR(255) PRIMARY KEY id VARCHAR(255) PRIMARY KEY
...@@ -40,4 +39,4 @@ INSERT INTO Para (section, para, revisionFlag) VALUES ...@@ -40,4 +39,4 @@ INSERT INTO Para (section, para, revisionFlag) VALUES
('api', 'Some APIs offer multiple language bindings.', NULL); ('api', 'Some APIs offer multiple language bindings.', NULL);
SELECT * FROM Section; SELECT * FROM Section;
SELECT * FROM Para; SELECT * FROM Para;
\ No newline at end of file
DROP TABLE IF EXISTS Category2Article; DROP TABLE IF EXISTS Category2Article, Article, Category;
DROP TABLE IF EXISTS Article;
DROP TABLE IF EXISTS Category;
CREATE TABLE Category CREATE TABLE Category
( (
...@@ -58,9 +56,6 @@ VALUES ('hardware', 232434); ...@@ -58,9 +56,6 @@ VALUES ('hardware', 232434);
INSERT INTO Category2Article INSERT INTO Category2Article
VALUES ('food', 544343); VALUES ('food', 544343);
SELECT * SELECT * FROM Category;
FROM Category; SELECT * FROM Article;
SELECT * SELECT * FROM Category2Article;
FROM Article; \ No newline at end of file
SELECT *
FROM Category2Article;
\ No newline at end of file
DROP TABLE IF EXISTS Student; DROP TABLE IF EXISTS Student, StudyCourse;
DROP TABLE IF EXISTS StudyCourse;
CREATE TABLE StudyCourse ( CREATE TABLE StudyCourse (
id INTEGER NOT NULL PRIMARY KEY id INTEGER NOT NULL PRIMARY KEY
......
DROP TABLE IF EXISTS Student; DROP TABLE IF EXISTS Student, StudyCourse;
DROP TABLE IF EXISTS StudyCourse;
CREATE TABLE StudyCourse ( CREATE TABLE StudyCourse (
id INTEGER NOT NULL PRIMARY KEY id INTEGER NOT NULL PRIMARY KEY
......
DROP TABLE IF EXISTS Description; DROP TABLE IF EXISTS Description, Product;
DROP TABLE IF EXISTS Product;
CREATE TABLE Product ( CREATE TABLE Product (
id INTEGER NOT NULL PRIMARY KEY id INTEGER NOT NULL PRIMARY KEY
......
DROP TABLE IF EXISTS Description; DROP TABLE IF EXISTS Description, Product;
DROP TABLE IF EXISTS Product;
CREATE TABLE Product ( CREATE TABLE Product (
id INTEGER NOT NULL PRIMARY KEY id INTEGER NOT NULL PRIMARY KEY
......
DROP TABLE IF EXISTS Course; DROP TABLE IF EXISTS Course, Lecturer;
DROP TABLE IF EXISTS Lecturer;
CREATE TABLE Lecturer ( CREATE TABLE Lecturer (
id INT AUTO_INCREMENT id INT AUTO_INCREMENT
......
DROP TABLE IF EXISTS Flight, Destination, Airline;
DROP TABLE IF EXISTS Flight;
DROP TABLE IF EXISTS Destination;
DROP TABLE IF EXISTS Airline;
CREATE Table Airline ( CREATE Table Airline (
id INT NOT NULL id INT NOT NULL
...@@ -42,4 +39,4 @@ CREATE TABLE Flight ( ...@@ -42,4 +39,4 @@ CREATE TABLE Flight (
\ No newline at end of file
DROP TABLE IF EXISTS Description; DROP TABLE IF EXISTS Description, Product;
DROP TABLE IF EXISTS Product;
CREATE TABLE Product ( CREATE TABLE Product (
id INTEGER NOT NULL PRIMARY KEY id INTEGER NOT NULL PRIMARY KEY
......
DROP TABLE IF EXISTS Description; DROP TABLE IF EXISTS Description, Product;
DROP TABLE IF EXISTS Product;
CREATE TABLE Product ( CREATE TABLE Product (
id INTEGER NOT NULL PRIMARY KEY id INTEGER NOT NULL PRIMARY KEY
...@@ -30,4 +29,4 @@ INSERT INTO Description VALUES(2, 2, 'Pre-attached tent poles'); ...@@ -30,4 +29,4 @@ INSERT INTO Description VALUES(2, 2, 'Pre-attached tent poles');
SELECT * FROM Product; SELECT * FROM Product;
-- this should fail due to a foreign key constraint: -- -- this should fail due to a foreign key constraint: --
DELETE FROM Product WHERE id=1; DELETE FROM Product WHERE id=1;
\ No newline at end of file
DROP TABLE IF EXISTS Description; DROP TABLE IF EXISTS Description, Product;
DROP TABLE IF EXISTS Product;
CREATE TABLE Product ( CREATE TABLE Product (
id INTEGER NOT NULL PRIMARY KEY id INTEGER NOT NULL PRIMARY KEY
......
DROP TABLE IF EXISTS Description; DROP TABLE IF EXISTS Description, Product;
DROP TABLE IF EXISTS Product;
CREATE TABLE Product ( CREATE TABLE Product (
id CHAR(20) NOT NULL PRIMARY KEY id CHAR(20) NOT NULL PRIMARY KEY
......
DROP TABLE IF EXISTS Description; DROP TABLE IF EXISTS Description, Product;
DROP TABLE IF EXISTS Product;
CREATE TABLE Product ( CREATE TABLE Product (
id INTEGER NOT NULL id INTEGER NOT NULL
......
-- possible present from a related exercise -- possible present from a related exercise
DROP TABLE IF EXISTS Description; DROP TABLE IF EXISTS Description, Product;
DROP TABLE IF EXISTS Product;
CREATE TABLE Product( CREATE TABLE Product(
orderNo CHAR(10) NOT NULL PRIMARY KEY orderNo CHAR(10) NOT NULL PRIMARY KEY
...@@ -12,4 +10,4 @@ INSERT INTO Product VALUES('x-223', 330.20); ...@@ -12,4 +10,4 @@ INSERT INTO Product VALUES('x-223', 330.20);
INSERT INTO Product VALUES('w-124', 110.40); INSERT INTO Product VALUES('w-124', 110.40);
INSERT INTO Product VALUES('3218', 330.20); INSERT INTO Product VALUES('3218', 330.20);
INSERT INTO Product VALUES('9921', 110.40); INSERT INTO Product VALUES('9921', 110.40);
\ No newline at end of file
DROP Table IF EXISTS SysUserGroup; DROP Table IF EXISTS SysUserGroup, SysUser, SysGroup;
DROP Table IF EXISTS SysUser;
DROP Table IF EXISTS SysGroup;
CREATE TABLE SysGroup ( -- The system's groups -- CREATE TABLE SysGroup ( -- The system's groups --
id INTEGER AUTO_INCREMENT PRIMARY KEY id INTEGER AUTO_INCREMENT PRIMARY KEY
......
drop table if exists Employee; drop table if exists EmployeeProject, Project, Employee, Department;
drop table if exists Project;
drop table if exists Department;
drop table if exists EmployeeProject;
CREATE TABLE Department( CREATE TABLE Department(
id BIGINT PRIMARY KEY id BIGINT PRIMARY KEY
...@@ -32,4 +29,4 @@ CREATE TABLE EmployeeProject ( ...@@ -32,4 +29,4 @@ CREATE TABLE EmployeeProject (
,project BIGINT NOT NULL REFERENCES Project ,project BIGINT NOT NULL REFERENCES Project
,PRIMARY KEY(employee, project) ,PRIMARY KEY(employee, project)
,weeklyHours INTEGER NOT NULL ,weeklyHours INTEGER NOT NULL
) )
\ No newline at end of file
drop table if exists Employee; drop table if exists EmployeeProject, Employee, Project, Department;
drop table if exists Project;
drop table if exists Department;
drop table if exists EmployeeProject;
CREATE TABLE Department( CREATE TABLE Department(
id BIGINT PRIMARY KEY id BIGINT PRIMARY KEY
...@@ -31,4 +28,4 @@ CREATE TABLE EmployeeProject ( ...@@ -31,4 +28,4 @@ CREATE TABLE EmployeeProject (
,project BIGINT NOT NULL REFERENCES Project ,project BIGINT NOT NULL REFERENCES Project
,PRIMARY KEY(employee, project) ,PRIMARY KEY(employee, project)
,weeklyHours INTEGER NOT NULL ,weeklyHours INTEGER NOT NULL
) )
\ No newline at end of file
-- possible present from a related exercise -- possible present from a related exercise
DROP TABLE IF EXISTS Description; DROP TABLE IF EXISTS Description, Product;
DROP TABLE IF EXISTS Product;
CREATE TABLE Product( CREATE TABLE Product(
orderNo CHAR(10) NOT NULL PRIMARY KEY orderNo CHAR(10) NOT NULL PRIMARY KEY
......
drop table if exists ArtistAlbum; drop table if exists ArtistAlbum, Artist, Track, Album, Format;
drop table if exists Artist;
drop table if exists Track;
drop table if exists Album;
drop table if exists Format;
CREATE TABLE Format ( CREATE TABLE Format (
id BIGINT PRIMARY KEY id BIGINT PRIMARY KEY
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment