Commit e6594ae2 authored by mi's avatar mi

Simplifying multipe «drop table» statements

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