Main Diagram

Generated using DbSchema

Main Diagram

img

Table company.contracts

IdxNameData TypeDescription
* 🔑contract_idINTThis column contains private informations.
🔍employee_idINT
contract_typeVARCHAR(50)
🔎 ⬈start_dateDATE
end_dateDATE
salaryDECIMAL(10,2)
Indexes
TypeNameOn
🔑pk_contractsON contract_id
🔍unq_contracts_employee_idON employee_id
🔎fk_contracts_salariesON start_date
Foreign Keys
TypeNameOn
fk_contracts_salaries( start_date ) ref company.salaries (effective_date)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.customers

IdxNameData Type
* 🔑 ⬋customer_idINT
first_nameVARCHAR(50)
last_nameVARCHAR(50)
emailVARCHAR(100)
phone_numberVARCHAR(20)
addressVARCHAR(255)
registration_dateDATE
Indexes
TypeNameOn
🔑pk_customersON customer_id
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.employee_benefits

IdxNameData Type
* 🔑benefit_idINT
🔍 ⬋employee_idINT
benefit_typeVARCHAR(50)
start_dateDATE
end_dateDATE
Indexes
TypeNameOn
🔑pk_employee_benefitsON benefit_id
🔍unq_employee_benefits_employee_idON employee_id
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.employee_projects

IdxNameData Type
* 🔑employee_idINT
* 🔑 ⬋project_idINT
roleVARCHAR(100)
start_dateDATE
end_dateDATE
Indexes
TypeNameOn
🔑pk_employee_projectsON employee_id, project_id
🔍unq_employee_projects_project_idON project_id
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.employees

This field contains personal informations

IdxNameData TypeDescription
* 🔑 ⬈employee_idINT
🔍first_nameVARCHAR(50)
last_nameVARCHAR(50)
emailVARCHAR(100)
hire_dateDATE
🔍 ⬈salaryDECIMAL(10,2)This column contains personal informations.
department_idINT
manager_idINT
Indexes
TypeNameOn
🔑pk_employeesON employee_id
🔍unq_employees_salaryON salary
🔍unq_employees_first_nameON first_name
Foreign Keys
TypeNameOn
fk_employees_employee_benefits( employee_id ) ref company.employee_benefits (employee_id)
fk_employees_employee_projects( employee_id ) ref company.employee_projects (project_id)
fk_employees_salaries( salary ) ref company.salaries (salary)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.inventory

IdxNameData Type
* 🔑inventory_idINT
🔍 ⬈product_idINT
warehouse_locationVARCHAR(100)
stock_quantityINT
reorder_levelINT
Indexes
TypeNameOn
🔑pk_inventoryON inventory_id
🔍unq_inventory_product_idON product_id
Foreign Keys
TypeNameOn
Virfk_inventory_products( product_id ) ref company.products (product_id)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.order_details

IdxNameData Type
* 🔎order_idINT
order_dateDATE
🔎 ⬈descriptionINT
end_dateDATE DEFAULT curdate()
Indexes
TypeNameOn
🔎fk_order_details_shipping_detailsON description
🔎pk_order_detailsON order_id
Foreign Keys
TypeNameOn
fk_order_details_shipping_details( description ) ref company.shipping_details (shipping_id)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.order_items

IdxNameData Type
* 🔑order_item_idINT
🔎 ⬈order_idINT
product_idINT
quantityINT
priceDECIMAL(10,2)
Indexes
TypeNameOn
🔑pk_order_itemsON order_item_id
🔎fk_order_items_ordersON order_id
Foreign Keys
TypeNameOn
fk_order_items_orders( order_id ) ref company.orders (order_id)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.orders

IdxNameData Type
* 🔑 ⬋order_idINT
customer_idINT
order_dateDATE
total_amountDECIMAL(15,2)
statusVARCHAR(50)
shipping_addressVARCHAR(255)
Indexes
TypeNameOn
🔑pk_ordersON order_id
Foreign Keys
TypeNameOn
Virfk_orders_customers( customer_id ) ref company.customers (customer_id)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.payment_methods

IdxNameData Type
* 🔑 ⬋payment_method_idINT
🔎 ⬈customer_idINT
payment_typeVARCHAR(50)
payment_detailsVARCHAR(255)
expiration_dateDATE
Indexes
TypeNameOn
🔑pk_payment_methodsON payment_method_id
🔎fk_payment_methods_customersON customer_id
Foreign Keys
TypeNameOn
fk_payment_methods_customers( customer_id ) ref company.customers (customer_id)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.product_price_log

IdxNameData Type
* 🔑log_idINT AUTO_INCREMENT
🔍 ⬈product_idINT
old_priceDECIMAL(10,2)
new_priceDECIMAL(10,2)
change_timeTIMESTAMP DEFAULT CURRENT_TIMESTAMP
Indexes
TypeNameOn
🔑pk_product_price_logON log_id
🔍unq_product_price_log_product_idON product_id
Foreign Keys
TypeNameOn
Virfk_product_price_log_inventory( product_id ) ref company.inventory (product_id)
Options

ENGINE=InnoDB AUTO_INCREMENT=201 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.products

IdxNameData Type
* 🔑 ⬋product_idINT
product_nameVARCHAR(100)
priceDECIMAL(10,2)
Indexes
TypeNameOn
🔑pk_productsON product_id
Triggers
NameDefinition

Trigger before_product_price_update

CREATE TRIGGER ${nameWithSchemaName} BEFORE UPDATE ON products FOR EACH ROW BEGIN
   IF OLD.price <> NEW.price THEN
       INSERT INTO company.product\_price\_log (product\_id, old\_price, new\_price)
       VALUES (OLD.product\_id, OLD.price, NEW.price);
   END IF;
END
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.projects

IdxNameData Type
* 🔑 ⬈project_idINT
project_nameVARCHAR(100)
🔍department_idINT
🔍 ⬋start_dateDATE
end_dateDATE
budgetDECIMAL(15,2)
statusVARCHAR(50)
Indexes
TypeNameOn
🔑pk_projectsON project_id
🔍unq_projects_department_idON department_id
🔍unq_projects_start_dateON start_date
Foreign Keys
TypeNameOn
fk_projects_employee_projects( project_id ) ref company.employee_projects (project_id)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.reviews

IdxNameData Type
* 🔑review_idINT
🔍product_idINT
🔎 ⬈customer_idINT
ratingINT
review_dateDATE
commentsTEXT
Indexes
TypeNameOn
🔑pk_reviewsON review_id
🔍unq_reviews_product_idON product_id
🔎fk_reviews_customersON customer_id
Foreign Keys
TypeNameOn
fk_reviews_customers( customer_id ) ref company.customers (customer_id)
Virfk_reviews_sales( customer_id ) ref company.sales (customer_id)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.salaries

IdxNameData Type
* 🔑 ⬈salary_idINT
🔍employee_idINT
🔍 ⬋salaryDECIMAL(10,2)
🔍 ⬋effective_dateDATE
bonusDECIMAL(10,2)
🔍customer_idINT
Indexes
TypeNameOn
🔑pk_salariesON salary_id
🔍unq_salaries_salaryON salary
🔍unq_salaries_employee_idON employee_id
🔍unq_salaries_effective_dateON effective_date
🔍unq_salaries_customer_idON customer_id
Foreign Keys
TypeNameOn
fk_salaries_customers( salary_id ) ref company.customers (customer_id)
fk_salaries_payment_methods( salary_id ) ref company.payment_methods (payment_method_id)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.sales

IdxNameData Type
* 🔑sales_idINT
priceDECIMAL(10,0)
discountDECIMAL(10,0)
🔎 ⬈customer_idINT
Indexes
TypeNameOn
🔑pk_salesON sales_id
🔎fk_sales_customersON customer_id
Foreign Keys
TypeNameOn
fk_sales_customers( customer_id ) ref company.customers (customer_id)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.shipping

IdxNameData Type
* 🔑 ⬋shipping_idINT
🔍 ⬋order_idINT
shipping_dateDATE
tracking_numberVARCHAR(50)
shipping_methodVARCHAR(50)
shipping_statusVARCHAR(50)
Indexes
TypeNameOn
🔑pk_shippingON shipping_id
🔍unq_shipping_order_idON order_id
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.shipping_details

IdxNameData Type
* 🔑 ⬈shipping_idINT
descriptionINT
* 🔎 ⬈ship_dateDATE DEFAULT curdate()
Indexes
TypeNameOn
🔑pk_shipping_detailsON shipping_id
🔎idx_shipping_details_ship_dateON ship_date
Foreign Keys
TypeNameOn
fk_shipping_details_projects( ship_date ) ref company.projects (start_date)
fk_shipping_details_shipping( shipping_id ) ref company.shipping (shipping_id)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.suppliers

IdxNameData Type
* 🔑 ⬈supplier_idINT
supplier_nameVARCHAR(100)
contact_nameVARCHAR(50)
contact_emailVARCHAR(100)
phone_numberVARCHAR(20)
addressVARCHAR(255)
Indexes
TypeNameOn
🔑pk_suppliersON supplier_id
Foreign Keys
TypeNameOn
fk_suppliers_shipping( supplier_id ) ref company.shipping (order_id)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Table company.transactions

IdxNameData Type
* 🔑transaction_idINT
🔎 ⬈order_idINT
transaction_dateDATE
amountDECIMAL(15,2)
payment_method_idINT
Indexes
TypeNameOn
🔑pk_transactionsON transaction_id
🔎fk_transactions_ordersON order_id
Foreign Keys
TypeNameOn
fk_transactions_orders( order_id ) ref company.orders (order_id)
Options

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci