Compare commits

...

2 commits

Author SHA1 Message Date
Alexander Ek
bf457f26d1 new database schema 2024-05-03 18:14:15 +02:00
Alexander Ek
e693a67b73 DATABASE SCHEMA 2024-05-03 18:10:32 +02:00
25 changed files with 222 additions and 41 deletions

View file

@ -1,5 +1,5 @@
--------------------------------------------
-- Recipe/Cookie related tables
-- Logistics/orders related tables
--------------------------------------------
-- Our known customers, may need more fields
@ -14,19 +14,71 @@ CREATE TABLE IF NOT EXISTS customers (
CREATE TABLE IF NOT EXISTS orders (
order_id int PRIMARY KEY,
customer_id int,
order_date date DEFAULT NOW,
delivery_date date, -- Set when the order hits the truck
order_datetime datetime DEFAULT NOW,
preferred_delivery_date DATE, --the table Delivery tells when the delivery is arrived
FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
);
CREATE TABLE IF NOT EXISTS delivery (
order_id INT,
truck_id INT,
delivery_datetime DATETIME,
PRIMARY KEY (order_id, truck_id),
FOREIGN KEY (order_id) REFERENCES orders(order_id)
);
CREATE TABLE IF NOT EXISTS OrderSpec (
order_id INT,
cookie_id INT,
quantity INT,
PRIMARY KEY (orderID, cookieID),
FOREIGN KEY (order_id) REFERENCES Orders(order_id),
FOREIGN KEY (cookie_id) REFERENCES Cookies(cookie_id)
);
CREATE TABLE IF NOT EXISTS pallet (
pallet_id INT PRIMARY KEY,
order_id INT,
cookie_id INT,
production_datetime DATETIME,
is_blocked BOOLEAN,
pallet_location VARCHAR(255),
FOREIGN KEY (order_id) REFERENCES Orders(order_id),
FOREIGN KEY (cookie_id) REFERENCES cookies(cookie_id)
);
--------------------------------------------
-- Recipe/Cookie related tables
--------------------------------------------
CREATE TABLE IF NOT EXISTS cookies (
cookie_id INT PRIMARY KEY,
recipe_id INT,
cookie_name VARCHAR(255),
price INT,
FOREIGN KEY (recipeID) REFERENCES Recipe(recipeID)
);
-- Recipes for all the cookies (essentially a list of cookies)
CREATE TABLE IF NOT EXISTS recipes (
recipe_id int PRIMARY KEY,
recipe_name varchar(100) UNIQUE -- Cookie name
cookie_id int,
recipe_name varchar(100) UNIQUE, -- Cookie name
FOREIGN KEY (cookie_id) REFERENCES cookies(cookie_id)
);
--weak table which descirbies the amout of the ingredient
--needed for a recipe
CREATE TABLE RecipeIngredients (
ingredient_id INT,
recipe_id INT,
quantity FLOAT,
PRIMARY KEY (ingredientID, recipeID),
FOREIGN KEY (ingredient_id) REFERENCES ingredients(ingredient_id),
FOREIGN KEY (recipe_id) REFERENCES recipes(recipe_id)
);
-- "The company has a raw materials warehouse in which
@ -37,47 +89,24 @@ CREATE TABLE IF NOT EXISTS recipes (
CREATE TABLE IF NOT EXISTS ingredients (
ingredient_id int PRIMARY KEY,
ingredient_name varchar(100),
amount int,
unit varchar(50)
in_stock float,
unit varchar(50),
amout_purchase float,
last_delivery DATETIME
);
-- Describes what ingredients goes into what recipe
-- Each recipe requires 'amount' of 'ingredient'
CREATE TABLE IF NOT EXISTS recipe_contents (
recipe_id int,
-- use this table instead of amount_purchase and last_delivery attributes
-- in ingrdients table if the assigment want us to have a purchase history
-- for every ingredient order.
/*
CREATE TABLE IF NOT EXISTS ingredient_purchase(
ingredientOrder_id
ingredient_id int,
amount int,
PRIMARY KEY (recipe_id, ingredient_id)
amout_purchase float,
delivery_datetime DATETIME,
FOREIGN KEY(ingreident_id) REFERENCES ingridients(ingridient_id)
);
*/
--------------------------------------------
-- Pallet related tables
--------------------------------------------
-- Pallets are used to store cookies for delivery
CREATE TABLE IF NOT EXISTS pallets (
pallet_id int PRIMARY KEY,
recipe_id int,
order_id int,
FOREIGN KEY (recipe_id) REFERENCES recipes(recipe_id),
FOREIGN KEY (order_id) REFERENCES Orders(order_id)
);
-- What does the pallet contain?
CREATE TABLE IF NOT EXISTS pallet_contents (
pallet_id int,
ingredient_id int,
amount int,
PRIMARY KEY (pallet_id, ingredient_id),
FOREIGN KEY (pallet_id) REFERENCES pallets(pallet_id),
FOREIGN KEY (ingredient_id) REFERENCES ingredients(ingredient_id)
);
-- Has an order been delivered?
-- When the truck is loaded, a delivery is considered done
CREATE TABLE IF NOT EXISTS delivery_bill (
delivery_id int PRIMARY KEY,
order_id int,
delivery_date date DEFAULT NOW,
FOREIGN KEY (order_id) REFERENCES Orders(order_id)
);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"><title>Krusty</title><link href="/static/css/main.59f83d58.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],i=r[1],a=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var i=t[l];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this.webpackJsonpfrontend=this.webpackJsonpfrontend||[],i=l.push.bind(l);l.push=r,l=l.slice();for(var a=0;a<l.length;a++)r(l[a]);var p=i;t()}([])</script><script src="/static/js/2.0a7bcc05.chunk.js"></script><script src="/static/js/main.4ee489f9.chunk.js"></script></body></html>

View file

@ -0,0 +1,2 @@
div.App{width:800px;margin:0 auto}@media screen and (max-width:800px){div.App{width:100%}}body{margin:10px;padding:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}code{font-family:source-code-pro,Menlo,Monaco,Consolas,"Courier New",monospace}
/*# sourceMappingURL=main.59f83d58.chunk.css.map */

View file

@ -0,0 +1 @@
{"version":3,"sources":["index.css"],"names":[],"mappings":"AAAA,QACC,WAAY,CACZ,aACD,CAEA,oCACE,QACE,UACF,CACF,CAEA,KACE,WAAY,CACZ,SAAU,CACV,mJAEY,CACZ,kCAAmC,CACnC,iCACF,CAEA,KACE,yEAEF","file":"main.59f83d58.chunk.css","sourcesContent":["div.App {\n\twidth: 800px;\n\tmargin: 0 auto;\n}\n\n@media screen and (max-width: 800px) {\n div.App {\n width: 100%;\n }\n}\n\nbody {\n margin: 10px;\n padding: 0;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\",\n \"Ubuntu\", \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\",\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, \"Courier New\",\n monospace;\n}\n"]}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,49 @@
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/**
* A better abstraction over CSS.
*
* @copyright Oleg Isonen (Slobodskoi) / Isonen 2014-present
* @website https://github.com/cssinjs/jss
* @license MIT
*/
/** @license React v0.18.0
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.12.0
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.12.0
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.12.0
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,2 @@
!function(e){function r(r){for(var n,f,l=r[0],i=r[1],a=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var i=t[l];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this.webpackJsonpfrontend=this.webpackJsonpfrontend||[],i=l.push.bind(l);l.push=r,l=l.slice();for(var a=0;a<l.length;a++)r(l[a]);var p=i;t()}([]);
//# sourceMappingURL=runtime-main.1c2d59f4.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,10 @@
{
"cookies": [
{"name": "Amneris"},
{"name": "Berliner"},
{"name": "Nut cookie"},
{"name": "Nut ring"},
{"name": "Tango"},
{"name": "Almond delight"}
]
}

View file

@ -0,0 +1,12 @@
{
"customers": [
{"name": "Bjudkakor AB", "address": "Ystad"},
{"name": "Finkakor AB", "address": "Helsingborg"},
{"name": "Gästkakor AB", "address": "Hässleholm"},
{"name": "Kaffebröd AB", "address": "Landskrona"},
{"name": "Kalaskakor AB", "address": "Trelleborg"},
{"name": "Partykakor AB", "address": "Kristianstad"},
{"name": "Skånekakor AB", "address": "Perstorp"},
{"name": "Småbröd AB", "address": "Malmö"}
]
}

View file

@ -0,0 +1,11 @@
{
"pallets": [
{"cookie": "Amneris", "blocked": "no"},
{"cookie": "Amneris", "blocked": "no"},
{"cookie": "Amneris", "blocked": "no"},
{"cookie": "Berliner", "blocked": "no"},
{"cookie": "Nut ring", "blocked": "no"},
{"cookie": "Nut ring", "blocked": "no"},
{"cookie": "Tango", "blocked": "no"}
]
}

View file

@ -0,0 +1,6 @@
{
"pallets": [
{"cookie": "Nut ring", "blocked": "no"},
{"cookie": "Nut ring", "blocked": "no"}
]
}

View file

@ -0,0 +1,4 @@
{
"pallets": [
]
}

View file

@ -0,0 +1,23 @@
{
"raw-materials": [
{"name": "Bread crumbs", "amount": 500000, "unit": "g"},
{"name": "Butter", "amount": 386600, "unit": "g"},
{"name": "Chocolate", "amount": 497300, "unit": "g"},
{"name": "Chopped almonds", "amount": 500000, "unit": "g"},
{"name": "Cinnamon", "amount": 500000, "unit": "g"},
{"name": "Egg whites", "amount": 500000, "unit": "ml"},
{"name": "Eggs", "amount": 456800, "unit": "g"},
{"name": "Fine-ground nuts", "amount": 500000, "unit": "g"},
{"name": "Flour", "amount": 416300, "unit": "g"},
{"name": "Ground, roasted nuts", "amount": 500000, "unit": "g"},
{"name": "Icing sugar", "amount": 474080, "unit": "g"},
{"name": "Marzipan", "amount": 378500, "unit": "g"},
{"name": "Potato starch", "amount": 495950, "unit": "g"},
{"name": "Roasted, chopped nuts", "amount": 475700, "unit": "g"},
{"name": "Sodium bicarbonate", "amount": 499784, "unit": "g"},
{"name": "Sugar", "amount": 486500, "unit": "g"},
{"name": "Vanilla", "amount": 499892, "unit": "g"},
{"name": "Vanilla sugar", "amount": 499730, "unit": "g"},
{"name": "Wheat flour", "amount": 495950, "unit": "g"}
]
}

View file

@ -0,0 +1,23 @@
{
"raw-materials": [
{"name": "Bread crumbs", "amount": 500000, "unit": "g"},
{"name": "Butter", "amount": 500000, "unit": "g"},
{"name": "Chocolate", "amount": 500000, "unit": "g"},
{"name": "Chopped almonds", "amount": 500000, "unit": "g"},
{"name": "Cinnamon", "amount": 500000, "unit": "g"},
{"name": "Egg whites", "amount": 500000, "unit": "ml"},
{"name": "Eggs", "amount": 500000, "unit": "g"},
{"name": "Fine-ground nuts", "amount": 500000, "unit": "g"},
{"name": "Flour", "amount": 500000, "unit": "g"},
{"name": "Ground, roasted nuts", "amount": 500000, "unit": "g"},
{"name": "Icing sugar", "amount": 500000, "unit": "g"},
{"name": "Marzipan", "amount": 500000, "unit": "g"},
{"name": "Potato starch", "amount": 500000, "unit": "g"},
{"name": "Roasted, chopped nuts", "amount": 500000, "unit": "g"},
{"name": "Sodium bicarbonate", "amount": 500000, "unit": "g"},
{"name": "Sugar", "amount": 500000, "unit": "g"},
{"name": "Vanilla", "amount": 500000, "unit": "g"},
{"name": "Vanilla sugar", "amount": 500000, "unit": "g"},
{"name": "Wheat flour", "amount": 500000, "unit": "g"}
]
}

Binary file not shown.