This database contains data from the [SQL Syntax website]. There are 8 tables with details relating to food suppliers. I will then design how my database will look as shown below:

<aside> 💡 DATA TABLE DETAILS

Coding in SQL


First, I created the data schema from MySQL Workbench with my own server.

CREATE SCHEMA `Food_logistic` ;

Untitled

Then, create all table in order to analyze the company insight. First, the customers data detail with unique number of customer_id as PRIMARY KEY

create table Customers(
	Customer_id int unique,
    Customer_name varchar(250),
    City varchar(100),
    Country varchar(100),
    primary key(Customer_id)
    );

insert into Customers(Customer_id, Customer_name, City, Country) 
values (1, 'Alfreds Futterkiste', "Berlin", "Germany"),
(2, 'Ana Trujillo', 'México D.F.', "Mexico"),
(3, 'Antonio Moreno Taquería', 'México D.F.', "Mexico"),

Untitled

Repeat doing creates table for all necessary data set with unique detail as PRIMARY KEY and the FOREIGN KEY constraint is used to prevent actions that would destroy links between tables.

create table Catagories(
	Catagory_id int unique,
    Catagory_name varchar(250),
    Description varchar(999),
    primary key(Catagory_id)
    );

insert into Catagories(Catagory_id, Catagory_name, Description) values
(1, "Beverages", "Soft drinks, coffees, teas, beers, and ales"),
(2, "Condiments", "Sweet and savory sauces, relishes, spreads, and seasonings"),

Untitled

create table Employees(
	Employee_id int unique,
    Lastname varchar(250),
    Firstname varchar(100),
    primary key(Employee_id)
    );
    
insert into Employees(Employee_id, Lastname, Firstname) values
(1, "Davolio", "Nancy"),
(2, "Fuller", "Andrew"),
(3, "Leverling", "Janet"),

Untitled

create table OrderDetails(
	OrderDetail_id int unique,
    Order_id int,
    Product_id int,
    Quantity int,
    primary key(OrderDetail_id)
    );
    
insert into OrderDetails(OrderDetail_id, Order_id, Product_id, Quantity) values
(1,	10248, 11, 12),
(2,	10248, 42, 10),
(3,	10248, 72, 5),

Untitled

create table Orders(
	Order_id int unique,
    Customer_id int,
    Employee_id int,
    Shipper_id int,
    primary key(Order_id),
    foreign key(Customer_id) references Customers(Customer_id),
    foreign key(Employee_id) references Employees(Employee_id),
    foreign key(Shipper_id) references Shippers(Shipper_id)
    );
    
insert into Orders values
(10248, 90, 5, 3),
(10249, 81, 6, 1),
(10250, 34, 4, 2),