54 lines
2.8 KiB
SQL
54 lines
2.8 KiB
SQL
CREATE TABLE IF NOT EXISTS Users (
|
|
id INTEGER PRIMARY KEY,
|
|
username TEXT NOT NULL UNIQUE,
|
|
password TEXT NOT NULL,
|
|
first_name TEXT NOT NULL,
|
|
last_name TEXT NOT NULL,
|
|
email TEXT NOT NULL UNIQUE,
|
|
phone TEXT NOT NULL,
|
|
role TEXT NOT NULL
|
|
);
|
|
|
|
INSERT INTO Users (first_name, last_name, username, email, phone, password, role) VALUES ("Luke", "Else", "lukejelse04", "test@test.com", "07498 289321", "test213", "Customer");
|
|
|
|
CREATE TABLE IF NOT EXISTS Products (
|
|
id INTEGER PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
image TEXT NOT NULL,
|
|
description TEXT NOT NULL,
|
|
cost DECIMAL NOT NULL,
|
|
sellerID INTEGER NOT NULL
|
|
REFERENCES Users (id)
|
|
ON DELETE CASCADE
|
|
ON UPDATE NO ACTION,
|
|
category TEXT NOT NULL
|
|
);
|
|
|
|
INSERT INTO Products (name, image, description, cost, sellerID, category) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, "CarParts");
|
|
INSERT INTO Products (name, image, description, cost, sellerID, category) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, "CarParts");
|
|
INSERT INTO Products (name, image, description, cost, sellerID, category) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, "CarParts");
|
|
INSERT INTO Products (name, image, description, cost, sellerID, category) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, "CarParts");
|
|
INSERT INTO Products (name, image, description, cost, sellerID, category) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, "CarParts");
|
|
INSERT INTO Products (name, image, description, cost, sellerID, category) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, "CarParts");
|
|
INSERT INTO Products (name, image, description, cost, sellerID, category) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, "CarParts");
|
|
INSERT INTO Products (name, image, description, cost, sellerID, category) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, "CarParts");
|
|
INSERT INTO Products (name, image, description, cost, sellerID, category) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, "CarParts");
|
|
INSERT INTO Products (name, image, description, cost, sellerID, category) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, "CarParts");
|
|
INSERT INTO Products (name, image, description, cost, sellerID, category) VALUES ("test", "assets/img/wmgzon.png", "this is a product", 20.99, 1, "CarParts");
|
|
|
|
CREATE TABLE IF NOT EXISTS Orders (
|
|
id INTEGER PRIMARY KEY,
|
|
sellerID TEXT NOT NULL
|
|
REFERENCES Users (id)
|
|
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
|
|
);
|
|
|
|
|