2024-01-01 16:20:44 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS Users (
|
|
|
|
id INTEGER PRIMARY KEY,
|
2024-01-02 22:22:14 +00:00
|
|
|
username TEXT NOT NULL UNIQUE,
|
|
|
|
password TEXT NOT NULL,
|
2024-01-01 16:20:44 +00:00
|
|
|
first_name TEXT NOT NULL,
|
|
|
|
last_name TEXT NOT NULL,
|
|
|
|
email TEXT NOT NULL UNIQUE,
|
2024-01-02 22:22:14 +00:00
|
|
|
phone TEXT NOT NULL,
|
2024-01-01 16:20:44 +00:00
|
|
|
role TEXT NOT NULL
|
|
|
|
);
|
|
|
|
|
2024-01-05 18:20:56 +00:00
|
|
|
INSERT INTO Users (first_name, last_name, username, email, phone, password, role) VALUES ("Luke", "Else", "lukejelse04", "test@test.com", "07498 289321", "test213", "Customer");
|
2024-01-01 16:20:44 +00:00
|
|
|
|
2024-01-06 01:14:20 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS Categories (
|
|
|
|
id INTEGER PRIMARY KEY,
|
|
|
|
name TEXT NOT NULL UNIQUE
|
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO Categories (name) VALUES ("Car Parts");
|
|
|
|
INSERT INTO Categories (name) VALUES ("Animals");
|
|
|
|
INSERT INTO Categories (name) VALUES ("Sports");
|
|
|
|
INSERT INTO Categories (name) VALUES ("Books");
|
|
|
|
INSERT INTO Categories (name) VALUES ("Phones");
|
|
|
|
INSERT INTO Categories (name) VALUES ("Music");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-01 16:20:44 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS Products (
|
|
|
|
id INTEGER PRIMARY KEY,
|
|
|
|
name TEXT NOT NULL,
|
2024-01-05 18:20:56 +00:00
|
|
|
image TEXT NOT NULL,
|
|
|
|
description TEXT NOT NULL,
|
2024-01-01 16:20:44 +00:00
|
|
|
cost DECIMAL NOT NULL,
|
|
|
|
sellerID INTEGER NOT NULL
|
|
|
|
REFERENCES Users (id)
|
|
|
|
ON DELETE CASCADE
|
|
|
|
ON UPDATE NO ACTION,
|
2024-01-06 01:14:20 +00:00
|
|
|
categoryID INTEGER NOT NULL
|
|
|
|
REFERENCES Categories (id)
|
|
|
|
ON DELETE CASCADE
|
|
|
|
ON UPDATE NO ACTION
|
2024-01-01 16:20:44 +00:00
|
|
|
);
|
|
|
|
|
2024-01-06 01:14:20 +00:00
|
|
|
INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, 1);
|
|
|
|
INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, 1);
|
|
|
|
INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, 1);
|
|
|
|
INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, 1);
|
2024-01-07 13:47:09 +00:00
|
|
|
INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 2, 2);
|
|
|
|
INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 3, 3);
|
|
|
|
INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 3, 3);
|
|
|
|
INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 3, 3);
|
|
|
|
INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 6, 6);
|
|
|
|
INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 6, 6);
|
|
|
|
INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 5, 5);
|
2024-01-01 16:20:44 +00:00
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS Orders (
|
|
|
|
id INTEGER PRIMARY KEY,
|
|
|
|
sellerID TEXT NOT NULL
|
2024-01-01 20:19:57 +00:00
|
|
|
REFERENCES Users (id)
|
2024-01-01 16:20:44 +00:00
|
|
|
ON DELETE NO ACTION
|
|
|
|
ON UPDATE NO ACTION,
|
|
|
|
total DECIMAL NOT NULL,
|
|
|
|
buyerID INTEGER NOT NULL
|
|
|
|
REFERENCES Users (id)
|
|
|
|
ON DELETE CASCADE
|
|
|
|
ON UPDATE NO ACTION,
|
|
|
|
orderDate DATE NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
|