From 87ba5bb679b701d78f249b815aa33c9b892d0024 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Fri, 3 May 2024 01:59:07 +0200 Subject: [PATCH] Snake case table names --- app/Migrations/0010-tables.sql | 120 ++++++++++++++++----------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/app/Migrations/0010-tables.sql b/app/Migrations/0010-tables.sql index 23f64bd..67fc49c 100644 --- a/app/Migrations/0010-tables.sql +++ b/app/Migrations/0010-tables.sql @@ -1,88 +1,88 @@ -CREATE TABLE IF NOT EXISTS Customers ( - CustomerID int PRIMARY KEY, - Name varchar(100), - Address varchar(255) +CREATE TABLE IF NOT EXISTS customers ( + customer_id int PRIMARY KEY, + name varchar(100), + address varchar(255) ); -CREATE TABLE IF NOT EXISTS Products ( - ProductID int PRIMARY KEY, - Name varchar(100) +CREATE TABLE IF NOT EXISTS products ( + product_id int PRIMARY KEY, + name varchar(100) ); -CREATE TABLE IF NOT EXISTS Recipes ( - RecipeName varchat(100), - RecipeYear Year, - ingrediences int, - ProductID int, - PRIMARY KEY (RecipeName, RecipeYear), - FOREIGN KEY (ingrediences) REFERENCES ingredience(IngredienceID), - FOREIGN KEY (ProductID) REFERENCES Products(ProductID) +CREATE TABLE IF NOT EXISTS recipes ( + recipe_name varchar(100), + recipe_year year, + ingredients int, + product_id int, + PRIMARY KEY (recipe_name, recipe_year), + FOREIGN KEY (ingredients) REFERENCES ingredients(ingredient_id), + FOREIGN KEY (product_id) REFERENCES products(product_id) ); -CREATE TABLE IF NOT EXISTS ingredience ( - IngredienceID int PRIMARY KEY, - RawMaterialName varchar(100), +CREATE TABLE IF NOT EXISTS ingredients ( + ingredient_id int PRIMARY KEY, + raw_material_name varchar(100), amount int, unit varchar(50), - FOREIGN KEY (RawMaterialName) REFERENCES RawMaterials(RawMaterialName) + FOREIGN KEY (raw_material_name) REFERENCES raw_materials(raw_material_name) ); -CREATE TABLE IF NOT EXISTS RawMaterials ( - RawMaterialName varchar(100) PRIMARY KEY, - Quantity int, - LastDeliveryDateTime datetime +CREATE TABLE IF NOT EXISTS raw_materials ( + raw_material_name varchar(100) PRIMARY KEY, + quantity int, + last_delivery_date_time datetime ); -CREATE TABLE IF NOT EXISTS PalletsProduced ( - PalletID int PRIMARY KEY, - ProductID int, - ProductionDateTime datetime, - FOREIGN KEY (ProductID) REFERENCES Products (ProductID) +CREATE TABLE IF NOT EXISTS pallets_produced ( + pallet_id int PRIMARY KEY, + product_id int, + production_date_time datetime, + FOREIGN KEY (product_id) REFERENCES products (product_id) ); -CREATE TABLE IF NOT EXISTS PalletsDelivered ( - DeliveredID int PRIMARY KEY, - PalletID int, - DeliveryDateTime datetime, - FOREIGN KEY (PalletID) REFERENCES PalletsProduced (PalletID), - FOREIGN KEY (DeliveredID) REFERENCES Truck (Pallet) +CREATE TABLE IF NOT EXISTS pallets_delivered ( + delivered_id int PRIMARY KEY, + pallet_id int, + delivery_date_time datetime, + FOREIGN KEY (pallet_id) REFERENCES pallets_produced (pallet_id), + FOREIGN KEY (delivered_id) REFERENCES truck (pallet) ); -CREATE TABLE IF NOT EXISTS Truck ( - truckId int PRIMARY KEY, +CREATE TABLE IF NOT EXISTS truck ( + truck_id int PRIMARY KEY, capacity int, - Pallet int + pallet int ); -CREATE TABLE IF NOT EXISTS loadingBill ( - LoadingbillID int PRIMARY KEY, - adress varchar(100), +CREATE TABLE IF NOT EXISTS loading_bill ( + loadingbill_id int PRIMARY KEY, + address varchar(100), customer varchar(100), - truckID int, - FOREIGN KEY (truckID) REFERENCES Truck (truckId) + truck_id int, + FOREIGN KEY (truck_id) REFERENCES truck (truck_id) ); -CREATE TABLE IF NOT EXISTS Orders ( - OrderID int PRIMARY KEY, - CustomerID int, - ProductID int, - Quantity int, - OrderDateTime datetime, - FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), - FOREIGN KEY (ProductID) REFERENCES Products (ProductID) +CREATE TABLE IF NOT EXISTS orders ( + order_id int PRIMARY KEY, + customer_id int, + product_id int, + quantity int, + order_date_time datetime, + FOREIGN KEY (customer_id) REFERENCES customers (customer_id), + FOREIGN KEY (product_id) REFERENCES products (product_id) ); -CREATE TABLE IF NOT EXISTS BlockedProducts ( - BlockedProductID int PRIMARY KEY, - ProductID int, - BlockedDateTime datetime, - FOREIGN KEY (ProductID) REFERENCES Products (ProductID) +CREATE TABLE IF NOT EXISTS blocked_products ( + blocked_product_id int PRIMARY KEY, + product_id int, + blocked_date_time datetime, + FOREIGN KEY (product_id) REFERENCES products (product_id) ); -CREATE TABLE IF NOT EXISTS PalletTraceability ( - TraceID int PRIMARY KEY, +CREATE TABLE IF NOT EXISTS pallet_traceability ( + trace_id int PRIMARY KEY, location varchar(100), - locationdate datetime, - PalletID int, - FOREIGN KEY (PalletID) REFERENCES PalletsProduced (PalletID) + location_date datetime, + pallet_id int, + FOREIGN KEY (pallet_id) REFERENCES pallets_produced (pallet_id) );