db_id
stringclasses 127
values | query
stringlengths 20
523
| question
stringlengths 16
224
| schema
stringclasses 127
values |
---|---|---|---|
workshop_paper | SELECT Author FROM submission WHERE College = "Florida" OR College = "Temple" | Show the names of authors from college "Florida" or "Temple" |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT Author FROM submission WHERE College = "Florida" OR College = "Temple" | Which authors with submissions are from college "Florida" or "Temple"? |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT avg(Scores) FROM submission | What is the average score of submissions? |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT avg(Scores) FROM submission | Compute the average score of submissions. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT Author FROM submission ORDER BY Scores DESC LIMIT 1 | What is the author of the submission with the highest score? |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT Author FROM submission ORDER BY Scores DESC LIMIT 1 | Find the author who achieved the highest score in a submission. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT College , COUNT(*) FROM submission GROUP BY College | Show different colleges along with the number of authors of submission from each college. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT College , COUNT(*) FROM submission GROUP BY College | For each college, return the college name and the count of authors with submissions from that college. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT College FROM submission GROUP BY College ORDER BY COUNT(*) DESC LIMIT 1 | Show the most common college of authors of submissions. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT College FROM submission GROUP BY College ORDER BY COUNT(*) DESC LIMIT 1 | Which college has the most authors with submissions? |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT College FROM submission WHERE Scores > 90 INTERSECT SELECT College FROM submission WHERE Scores < 80 | Show the colleges that have both authors with submission score larger than 90 and authors with submission score smaller than 80. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT College FROM submission WHERE Scores > 90 INTERSECT SELECT College FROM submission WHERE Scores < 80 | Which colleges have both authors with submission score above 90 and authors with submission score below 80? |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT T2.Author , T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID | Show the authors of submissions and the acceptance results of their submissions. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT T2.Author , T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID | For each submission, find its author and acceptance result. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID ORDER BY T2.Scores DESC LIMIT 1 | Show the result of the submission with the highest score. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID ORDER BY T2.Scores DESC LIMIT 1 | Which submission received the highest score in acceptance result. Show me the result. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT T2.Author , COUNT(DISTINCT T1.workshop_id) FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author | Show each author and the number of workshops they submitted to. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT T2.Author , COUNT(DISTINCT T1.workshop_id) FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author | How many workshops did each author submit to? Return the author name and the number of workshops. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT T2.Author FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author HAVING COUNT(DISTINCT T1.workshop_id) > 1 | Show the authors who have submissions to more than one workshop. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT T2.Author FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author HAVING COUNT(DISTINCT T1.workshop_id) > 1 | Which authors have submitted to more than one workshop? |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT Date , Venue FROM workshop ORDER BY Venue | Show the date and venue of each workshop in ascending alphabetical order of the venue. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT Date , Venue FROM workshop ORDER BY Venue | Sort the each workshop in alphabetical order of the venue. Return the date and venue of each workshop. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT Author FROM submission WHERE Submission_ID NOT IN (SELECT Submission_ID FROM acceptance) | List the authors who do not have submission to any workshop. |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
workshop_paper | SELECT Author FROM submission WHERE Submission_ID NOT IN (SELECT Submission_ID FROM acceptance) | Which authors did not submit to any workshop? |
PRAGMA foreign_keys = ON;
CREATE TABLE "workshop" (
"Workshop_ID" int,
"Date" text,
"Venue" text,
"Name" text,
PRIMARY KEY ("Workshop_ID")
);
CREATE TABLE "submission" (
"Submission_ID" int,
"Scores" real,
"Author" text,
"College" text,
PRIMARY KEY ("Submission_ID")
);
CREATE TABLE "Acceptance" (
"Submission_ID" int,
"Workshop_ID" int,
"Result" text,
PRIMARY KEY ("Submission_ID","Workshop_ID"),
FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"),
FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID")
);
INSERT INTO "workshop" VALUES (1,"August 18, 2007","London UK","ABC 2007");
INSERT INTO "submission" VALUES ("1","72","Steve Niehaus","Notre Dame");
INSERT INTO "Acceptance" VALUES (2,5,"Accepted");
|
tracking_share_transactions | SELECT count(*) FROM INVESTORS | Find the number of investors in total. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT Investor_details FROM INVESTORS | Show all investor details. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT DISTINCT lot_details FROM LOTS | Show all distinct lot details. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT max(amount_of_transaction) FROM TRANSACTIONS | Show the maximum amount of transaction. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT date_of_transaction , share_count FROM TRANSACTIONS | Show all date and share count of transactions. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT sum(share_count) FROM TRANSACTIONS | What is the total share of transactions? | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT transaction_id FROM TRANSACTIONS WHERE transaction_type_code = 'PUR' | Show all transaction ids with transaction code 'PUR'. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT date_of_transaction FROM TRANSACTIONS WHERE transaction_type_code = "SALE" | Show all dates of transactions whose type code is "SALE". | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT avg(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "SALE" | Show the average amount of transactions with type code "SALE". | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT transaction_type_description FROM Ref_Transaction_Types WHERE transaction_type_code = "PUR" | Show the description of transaction type with code "PUR". | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT min(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "PUR" AND share_count > 50 | Show the minimum amount of transactions whose type code is "PUR" and whose share count is bigger than 50. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT max(share_count) FROM TRANSACTIONS WHERE amount_of_transaction < 10000 | Show the maximum share count of transactions where the amount is smaller than 10000 | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count > 100 OR amount_of_transaction > 1000 | Show the dates of transactions if the share count is bigger than 100 or the amount is bigger than 1000. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T1.transaction_type_description , T2.date_of_transaction FROM Ref_Transaction_Types AS T1 JOIN TRANSACTIONS AS T2 ON T1.transaction_type_code = T2.transaction_type_code WHERE T2.share_count < 10 | Show the transaction type descriptions and dates if the share count is smaller than 10. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.share_count > 100 | Show details of all investors if they make any transaction with share count greater than 100. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT COUNT(DISTINCT transaction_type_code) FROM TRANSACTIONS | How many distinct transaction types are used in the transactions? | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT lot_details , investor_id FROM LOTS | Return the lot details and investor ids. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T2.lot_details FROM INVESTORS AS T1 JOIN LOTS AS T2 ON T1.investor_id = T2.investor_id WHERE T1.Investor_details = "l" | Return the lot details of lots that belong to investors with details "l"? | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T1.purchase_details FROM PURCHASES AS T1 JOIN TRANSACTIONS AS T2 ON T1.purchase_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction > 10000 | What are the purchase details of transactions with amount bigger than 10000? | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T1.sales_details , T2.date_of_transaction FROM SALES AS T1 JOIN TRANSACTIONS AS T2 ON T1.sales_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction < 3000 | What are the sale details and dates of transactions with amount smaller than 3000? | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T1.lot_details FROM LOTS AS T1 JOIN TRANSACTIONS_LOTS AS T2 ON T1.lot_id = T2.transaction_id JOIN TRANSACTIONS AS T3 ON T2.transaction_id = T3.transaction_id WHERE T3.share_count < 50 | What are the lot details of lots associated with transactions with share count smaller than 50? | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T1.lot_details FROM LOTS AS T1 JOIN TRANSACTIONS_LOTS AS T2 ON T1.lot_id = T2.transaction_id JOIN TRANSACTIONS AS T3 ON T2.transaction_id = T3.transaction_id WHERE T3.share_count > 100 AND T3.transaction_type_code = "PUR" | What are the lot details of lots associated with transactions whose share count is bigger than 100 and whose type code is "PUR"? | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT transaction_type_code , avg(amount_of_transaction) FROM TRANSACTIONS GROUP BY transaction_type_code | Show the average transaction amount for different transaction types. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT transaction_type_code , max(share_count) , min(share_count) FROM TRANSACTIONS GROUP BY transaction_type_code | Show the maximum and minimum share count of different transaction types. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT investor_id , avg(share_count) FROM TRANSACTIONS GROUP BY investor_id | Show the average share count of transactions for different investors. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT investor_id , avg(share_count) FROM TRANSACTIONS GROUP BY investor_id ORDER BY avg(share_count) | Show the average share count of transactions each each investor, ordered by average share count. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT investor_id , avg(amount_of_transaction) FROM TRANSACTIONS GROUP BY investor_id | Show the average amount of transactions for different investors. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T2.lot_id , avg(amount_of_transaction) FROM TRANSACTIONS AS T1 JOIN Transactions_Lots AS T2 ON T1.transaction_id = T2.transaction_id GROUP BY T2.lot_id | Show the average amount of transactions for different lots. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T2.lot_id , avg(amount_of_transaction) FROM TRANSACTIONS AS T1 JOIN Transactions_Lots AS T2 ON T1.transaction_id = T2.transaction_id GROUP BY T2.lot_id ORDER BY avg(amount_of_transaction) | Show the average amount of transactions for different lots, ordered by average amount of transactions. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT investor_id , COUNT(*) FROM TRANSACTIONS WHERE transaction_type_code = "SALE" GROUP BY investor_id | Show the number of transactions with transaction type code "SALE" for different investors if it is larger than 0. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT investor_id , COUNT(*) FROM TRANSACTIONS GROUP BY investor_id | Show the number of transactions for different investors. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code ORDER BY COUNT(*) ASC LIMIT 1 | Show the transaction type code that occurs the fewest times. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code ORDER BY COUNT(*) DESC LIMIT 1 | Show the transaction type code that occurs the most frequently. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T1.transaction_type_description FROM Ref_Transaction_Types AS T1 JOIN TRANSACTIONS AS T2 ON T1.transaction_type_code = T2.transaction_type_code GROUP BY T1.transaction_type_code ORDER BY COUNT(*) DESC LIMIT 1 | Show the description of the transaction type that occurs most frequently. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T2.investor_id , T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id ORDER BY COUNT(*) DESC LIMIT 1 | Show the id and details of the investor that has the largest number of transactions. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T2.investor_id , T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id ORDER BY COUNT(*) DESC LIMIT 3 | Show the id and details for the investors who have the top 3 number of transactions. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T2.investor_id FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id HAVING COUNT(*) >= 2 | Show the ids of the investors who have at least two transactions. | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT T2.investor_id , T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.transaction_type_code = "SALE" GROUP BY T2.investor_id HAVING COUNT(*) >= 2 | Show the ids and details of the investors who have at least two transactions with type code "SALE". | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count >= 100 OR amount_of_transaction >= 100 | What are the dates of transactions with at least 100 share count or amount bigger than 100? | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT sales_details FROM sales UNION SELECT purchase_details FROM purchases | What are the details of all sales and purchases? | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
tracking_share_transactions | SELECT lot_details FROM Lots EXCEPT SELECT T1.lot_details FROM Lots AS T1 JOIN transactions_lots AS T2 ON T1.lot_id = T2.lot_id | What are the details of the lots which are not used in any transactions? | PRAGMA foreign_keys = ON;
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z')INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r')INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale')INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL)INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x')INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c')INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11) |
cre_Theme_park | SELECT count(*) FROM HOTELS | How many available hotels are there in total? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT count(*) FROM HOTELS | Find the total number of available hotels. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT price_range FROM HOTELS | What are the price ranges of hotels? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT price_range FROM HOTELS | Tell me the price ranges for all the hotels. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT DISTINCT Location_Name FROM LOCATIONS | Show all distinct location names. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT DISTINCT Location_Name FROM LOCATIONS | What are the distinct location names? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Name , Other_Details FROM Staff | Show the names and details of all the staff members. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Name , Other_Details FROM Staff | What is the name and detail of each staff member? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Tourist_Details FROM VISITORS | Show details of all visitors. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Tourist_Details FROM VISITORS | What is the detail of each visitor? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT price_range FROM HOTELS WHERE star_rating_code = "5" | Show the price ranges of hotels with 5 star ratings. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT price_range FROM HOTELS WHERE star_rating_code = "5" | What are the price ranges of five star hotels? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT avg(price_range) FROM HOTELS WHERE star_rating_code = "5" AND pets_allowed_yn = 1 | Show the average price range of hotels that have 5 star ratings and allow pets. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT avg(price_range) FROM HOTELS WHERE star_rating_code = "5" AND pets_allowed_yn = 1 | What is the average price range of five star hotels that allow pets? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Address FROM LOCATIONS WHERE Location_Name = "UK Gallery" | What is the address of the location "UK Gallery"? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Address FROM LOCATIONS WHERE Location_Name = "UK Gallery" | Find the address of the location named "UK Gallery". | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Other_Details FROM LOCATIONS WHERE Location_Name = "UK Gallery" | What is the detail of the location UK Gallery? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Other_Details FROM LOCATIONS WHERE Location_Name = "UK Gallery" | Return the detail of the location named "UK Gallery". | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Location_Name FROM LOCATIONS WHERE Location_Name LIKE "%film%" | Which location names contain the word "film"? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Location_Name FROM LOCATIONS WHERE Location_Name LIKE "%film%" | Find all the locations whose names contain the word "film". | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT count(DISTINCT Name) FROM PHOTOS | How many distinct names are associated with all the photos? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT count(DISTINCT Name) FROM PHOTOS | Count the number of distinct names associated with the photos. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT DISTINCT Visit_Date FROM VISITS | What are the distinct visit dates? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT DISTINCT Visit_Date FROM VISITS | Find all the distinct visit dates. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Name FROM TOURIST_ATTRACTIONS WHERE How_to_Get_There = "bus" | What are the names of the tourist attractions that can be accessed by bus? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Name FROM TOURIST_ATTRACTIONS WHERE How_to_Get_There = "bus" | Which tourist attractions can we get to by bus? Tell me the names of the attractions. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Name , Opening_Hours FROM TOURIST_ATTRACTIONS WHERE How_to_Get_There = "bus" OR How_to_Get_There = "walk" | What are the names and opening hours of the tourist attractions that can be accessed by bus or walk? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT Name , Opening_Hours FROM TOURIST_ATTRACTIONS WHERE How_to_Get_There = "bus" OR How_to_Get_There = "walk" | Find the names and opening hours of the tourist attractions that we get to by bus or walk. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT T2.star_rating_description FROM HOTELS AS T1 JOIN Ref_Hotel_Star_Ratings AS T2 ON T1.star_rating_code = T2.star_rating_code WHERE T1.price_range > 10000 | What are the star rating descriptions of the hotels with price above 10000? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT T2.star_rating_description FROM HOTELS AS T1 JOIN Ref_Hotel_Star_Ratings AS T2 ON T1.star_rating_code = T2.star_rating_code WHERE T1.price_range > 10000 | Give me the star rating descriptions of the hotels that cost more than 10000. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT T1.Museum_Details , T2.Opening_Hours FROM MUSEUMS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Museum_ID = T2.Tourist_Attraction_ID | What are the details and opening hours of the museums? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT T1.Museum_Details , T2.Opening_Hours FROM MUSEUMS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Museum_ID = T2.Tourist_Attraction_ID | Give me the detail and opening hour for each museum. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT T2.Name FROM PHOTOS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID WHERE T1.Name = "game1" | What is the name of the tourist attraction that is associated with the photo "game1"? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT T2.Name FROM PHOTOS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID WHERE T1.Name = "game1" | Which tourist attraction is associated with the photo "game1"? Return its name. | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
cre_Theme_park | SELECT T1.Name , T1.Description FROM PHOTOS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID WHERE T2.Name = "film festival" | What are the names and descriptions of the photos taken at the tourist attraction "film festival"? | PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
INSERT INTO Locations (`Location_ID`, `Location_Name`, `Address`, `Other_Details`) VALUES (333, 'Astro Orbiter', '660 Shea Crescent', NULL)INSERT INTO Ref_Attraction_Types (`Attraction_Type_Code`, `Attraction_Type_Description`) VALUES ('2', 'park')INSERT INTO Ref_Hotel_Star_Ratings (`star_rating_code`, `star_rating_description`) VALUES ('1', 'star')INSERT INTO Visitors (`Tourist_ID`, `Tourist_Details`) VALUES (164, 'Toney')INSERT INTO Features (`Feature_ID`, `Feature_Details`) VALUES (523, 'cafe')INSERT INTO Hotels (`hotel_id`, `star_rating_code`, `pets_allowed_yn`, `price_range`, `other_hotel_details`) VALUES (123, '5', '1', '2914989.571', NULL)INSERT INTO Tourist_Attractions (`Tourist_Attraction_ID`, `Attraction_Type_Code`, `Location_ID`, `How_to_Get_There`, `Name`, `Description`, `Opening_Hours`, `Other_Details`) VALUES (2113, '2', 579, 'bus', 'art museum', NULL, NULL, NULL)INSERT INTO Museums (`Museum_ID`,`Museum_Details`) VALUES (2113,'Yale Center for British Art')INSERT INTO Theme_Parks (`Theme_Park_ID`,`Theme_Park_Details`) VALUES (5265,'Disney')INSERT INTO Street_Markets (`Market_ID`,`Market_Details`) VALUES (6852, 'Broadway')INSERT INTO Shops (`Shop_ID`,`Shop_Details`) VALUES (8429, 'soup')INSERT INTO Royal_Family (`Royal_Family_ID`,`Royal_Family_Details`) VALUES (9561,NULL)INSERT INTO Visits (`Visit_ID`, `Tourist_Attraction_ID`, `Tourist_ID`, `Visit_Date`, `Visit_Details`) VALUES (183, 6653, 377, '2004-08-21 03:06:14', '')INSERT INTO Photos (`Photo_ID`, `Tourist_Attraction_ID`, `Name`, `Description`, `Filename`, `Other_Details`) VALUES (211, 8449, 'game1', NULL, '702', NULL)INSERT INTO Staff (`Staff_ID`, `Tourist_Attraction_ID`, `Name`, `Other_Details`) VALUES (170, 6476, 'Whitney', NULL)INSERT INTO Tourist_Attraction_Features (`Tourist_Attraction_ID`, `Feature_ID`) VALUES (5076, 528) |
Subsets and Splits