From 55442b19c9896e364cebdf31148cd779743e0403 Mon Sep 17 00:00:00 2001
From: Sorrel Harriet <sharr003@igor.gold.ac.uk>
Date: Sun, 2 Oct 2016 21:28:51 +0100
Subject: [PATCH] correcting mistakes in schema

---
 lab-2/music-store-app/sql/schema.sql | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/lab-2/music-store-app/sql/schema.sql b/lab-2/music-store-app/sql/schema.sql
index 2bb7329..0999a25 100644
--- a/lab-2/music-store-app/sql/schema.sql
+++ b/lab-2/music-store-app/sql/schema.sql
@@ -1,14 +1,13 @@
 /* Delete existing tables in reverse order of creation
 so as not to violate any foreign key constraints */
-DROP TABLE IF EXISTS OrderLine, Order, Customer, Track, Album, Artist, Act, Genre;
+DROP TABLE IF EXISTS LineItem, Transaction, Customer, Track, Album, Artist, Act, Genre;
 
 /* Define table for genres */
 CREATE TABLE Genre (
 	id INT AUTO_INCREMENT,
 	name VARCHAR(25) UNIQUE NOT NULL,
 	PRIMARY KEY (id)
-}
-	
+);
 
 /* Define table for storing act (i.e. a group or solo artist) */
 CREATE TABLE Act (
@@ -18,7 +17,7 @@ CREATE TABLE Act (
 	PRIMARY KEY (id),
 	FOREIGN KEY (genre_id)
 		REFERENCES Genre (id)
-}
+);
 
 /* Define table for storing artists */
 CREATE TABLE Artist (
@@ -36,9 +35,10 @@ CREATE TABLE Album (
 	id INT AUTO_INCREMENT,
 	name VARCHAR(50) NOT NULL,
 	year YEAR(4),
-	compilation BOOLEAN NOT NULL DEFAULT 0
+	compilation BOOLEAN NOT NULL DEFAULT 0,
 	price DECIMAL(5, 2) unsigned NOT NULL,
-}
+	PRIMARY KEY (id)
+);
 
 
 /* Define table for storing single tracks */
@@ -69,7 +69,7 @@ CREATE TABLE Customer (
 );
 
 /* Define table for storing orders */
-CREATE TABLE Order (
+CREATE TABLE Transaction (
 	id INT AUTO_INCREMENT,
 	customer_id INT NOT NULL,
 	delivery ENUM('first class','second class','next working day'),
@@ -78,15 +78,15 @@ CREATE TABLE Order (
 		REFERENCES Customer(id)
 );
 
-/* Define table for storing orderlines */
-CREATE TABLE OrderLine (
+/* Define table for storing line items */
+CREATE TABLE LineItem (
 	id INT AUTO_INCREMENT,
-	order_id INT NOT NULL,
+	trans_id INT NOT NULL,
 	album_id INT NOT NULL,
-	quantity INT NOT NULL,
+	quantity INT NOT NULL DEFAULT 1,
 	PRIMARY KEY (id),
-	FOREIGN KEY (order_id)
-		REFERENCES Order(id),
+	FOREIGN KEY (trans_id)
+		REFERENCES Transaction (id),
 	FOREIGN KEY (album_id)
-		REFERENCES Album(id),
+		REFERENCES Album (id)
 );
-- 
GitLab