From 47cc1b042492797a8239ed2237417dfc3eee04f9 Mon Sep 17 00:00:00 2001 From: vextv Date: Tue, 15 Oct 2024 22:41:46 +0200 Subject: [PATCH] added example db create script --- .idea/sqldialects.xml | 7 +++ public/check-status.html | 2 +- sql/create_db.sql | 125 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 .idea/sqldialects.xml diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml new file mode 100644 index 0000000..2834bc7 --- /dev/null +++ b/.idea/sqldialects.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/public/check-status.html b/public/check-status.html index bf71fb7..6f71748 100644 --- a/public/check-status.html +++ b/public/check-status.html @@ -2,7 +2,7 @@ - + Document diff --git a/sql/create_db.sql b/sql/create_db.sql index 44dc8e9..3bc783e 100644 --- a/sql/create_db.sql +++ b/sql/create_db.sql @@ -1,5 +1,7 @@ CREATE DATABASE 'webshop' CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci; +# example link: https://fabric.inc/blog/commerce/ecommerce-database-design-example + CREATE TABLE 'user' ( id int, @@ -9,5 +11,124 @@ CREATE TABLE 'user' email varchar(255), passwd varchar(255), passwd_hash_algo varchar(255), - is_admin bool -) + is_admin bool, + created_at timestamp, + modified_at timestamp +); + +CREATE TABLE 'user_address' +( + id int, + userid int, + address_line1 varchar(255), + address_line2 varchar(255), + city varchar(255), + postal_code varchar(255), + country varchar(255), + telephone varchar(255), + mobile varchar(255) +); + +CREATE TABLE 'user_payment' +( + id int, + user_id int, + payment_type varchar(255), + provider varchar(255), + account_no int, + expiry date +); + +CREATE TABLE 'shopping_session' +( + id int, + user_id varchar(255), + total decimal, + created_at timestamp, + modified_at timestamp +); + +CREATE TABLE 'cart_item' +( + id int, + session_id int, + product_id int, + quantity int, + created_at timestamp, + modified_at timestamp +); + +CREATE TABLE 'payment_details' +( + id int, + order_id int, + amount int, + provider varchar(255), + status varchar(255), + created_at timestamp, + modified_at timestamp +); + +CREATE TABLE 'order_items' +( + id int, + order_id int, + product_id int, + quantity int, + created_at timestamp, + modified_at timestamp +); + +CREATE TABLE 'order_details' +( + id int, + user_id varchar(255), + total decimal, + payment_id int, + created_at timestamp, + modified_at timestamp +); + +CREATE TABLE 'product' +( + id int, + name varchar(255), + desc text, + SKU varchar(255), + category_id int, + inventory_id int, + price decimal, + discount_id int, + created_at timestamp, + modified_at timestamp, + deleted_at timestamp +); + +CREATE TABLE 'product_category' +( + id int, + name varchar(255), + desc text, + created_at timestamp, + modified_at timestamp, + deleted_at timestamp +); +CREATE TABLE 'product_inventory' +( + id int, + quantity int, + created_at timestamp, + modified_at timestamp, + deleted_at timestamp +); +CREATE TABLE 'discount' +( + id int, + name varchar(255), + desc text, + discount_percent decimal, + active bool, + created_at timestamp, + modified_at timestamp, + deleted_at timestamp +) \ No newline at end of file