0% found this document useful (0 votes)
14 views3 pages

SQL Ordermanagement

The document defines the schema for several database tables including categories, products, users, orders, and order details. Tables are created with the proper columns and constraints. Sample data is inserted into each table.

Uploaded by

nguyen95560
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

SQL Ordermanagement

The document defines the schema for several database tables including categories, products, users, orders, and order details. Tables are created with the proper columns and constraints. Sample data is inserted into each table.

Uploaded by

nguyen95560
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 3

-- bảng Category

CREATE TABLE [dbo].[Category] (


[id] INT IDENTITY (1, 1) NOT NULL,
[name] VARCHAR (255) NOT NULL,
PRIMARY KEY CLUSTERED ([id] ASC)
);

INSERT INTO [dbo].[Category] ([name])


VALUES
('Food'),
('Drink'),
('Combo');

-- bảng Product
CREATE TABLE [dbo].[Product] (
[id] INT IDENTITY (1, 1) NOT NULL,
[idcategory] INT NOT NULL,
[name] VARCHAR (255) NOT NULL,
[description] VARCHAR (255) NOT NULL,
[price] FLOAT (53) NOT NULL,
[image] VARCHAR (255) NOT NULL,
PRIMARY KEY CLUSTERED ([id] ASC),
FOREIGN KEY ([idcategory]) REFERENCES [dbo].[Category] ([id])
);

INSERT INTO [dbo].[Product] ([idcategory], [name], [description], [price], [image])


VALUES
(1, 'Pork meatball bread', 'Bread, pork meatball, salad, tomato, cucumber', 50, 'pork_meatball_bread.jpg'),
(1, 'Beef steak', 'Beef, lemon, salad, pepper, cucumber', 70, 'beef_steak.jpg'),
(1, 'Beef soup', 'Beef, water, red pumpkin, cilantro', 30, 'beef_soup.jpg'),
(1, 'Vegetable fried rice', 'Rice, egg, cucumber, pepper, cilantro', 40, 'vegetable_fried_rice.jpg'),
(1, 'Hamburger beef steak', 'Bread, beef, tomato, cheese', 30, 'hamburger_beef_steak.jpg'),
(1, 'Spaghetti', 'Pasta, tomato, cheese', 35, 'spaghetti.jpg'),
(1, 'Pasta with tomato sauce', 'Pasta, tomato, vegetable', 40, 'pasta_with_tomato_sauce.jpg'),
(1, 'Mixed pasta', 'Pasta, egg, tomato', 50, 'mixed_pasta.jpg'),
(1, 'Grilled pork', 'Pork, pepper, vegetable', 35, 'grilled_pork.jpg'),
(1, 'Middle rare beef', 'Beef, lemon, salad, pepper, cucumber', 60, 'middle_rare_beef.jpg'),
(2, 'Ice blended matcha', 'Matcha, ice, cheese cream', 20, 'ice_blended_matcha.jpg'),
(2, 'Carrot juice', 'Carrot, water, sugar', 20, 'carrot_juice.jpg'),
(2, 'Beetroot juice', 'Beetroot, water, sugar', 20, 'beetroot_juice.jpg'),
(2, 'Pineapple juice', 'Pineapple, green apple', 25, 'pineapple_juice.jpg'),
(2, 'Oreo mixed milk tea', 'Oreo, cheese cream, milk tea', 25, 'oreo_mixed_milk_tea.jpg'),
(2, 'Peach orange lemongrass tea', 'Tea, orange, lemongrass, peach', 25, 'peach_orange_lemongrass_tea.jpg'),
(2, 'Strawberry tea', 'Strawberry, tea, lemon, sugar', 25, 'strawberry_tea.jpg'),
(2, 'Cream cheese tea', 'Cream, cheese, tea', 20, 'cream_cheese_tea.jpg'),
(2, 'Brown sugar pearl milk tea', 'Brown sugar, milk tea, pearl', 25, 'brown_sugar_pearl_milk_tea.jpg'),
(2, 'Lemon tea', 'Lemon, tea, sugar', 15, 'lemon_tea.jpg'),
(3, 'Combo Korea for a family', 'Salad, traditional korea food, 2 drinks', 200, 'combo_korea_for_family.jpg'),
(3, 'Combo chicken soup', 'Chicken soup, 1 drink', 100, 'combo_chicken_soup.jpg'),
(3, 'Combo lunch meal for 2 people', 'Rice, kimchi, 3 foods, 2 drinks', 150, 'combo_lunch_meal_for_2.jpg'),
(3, 'Combo fast food', 'Spaghetti, pepsi, French fries', 100, 'combo_fast_food.jpg'),
(3, 'Combo kimbap korea', 'Kimbap, onigiri, fruit', 200, 'combo_kimbap_korea.jpg'),
(3, 'Combo hot pot', 'Seafood hotpot, drinks', 200, 'combo_hot_pot.jpg'),
(3, 'Combo salad', 'Salad, fruit', 100, 'combo_salad.jpg'),
(3, 'Combo Korean mixed rice', 'Korean mixed rice, drinks', 150, 'combo_korean_mixed_rice.jpg'),
(3, 'Combo Korean barbecue', 'Korean barbecue, drinks', 150, 'combo_korean_barbecue.jpg'),
(3, 'Combo kimbap for 1 person', 'Kimbap and drink', 80, 'combo_kimbap_for_1.jpg');

-- bảng User
CREATE TABLE [dbo].[User] (
[ID] INT NOT NULL,
[username] NVARCHAR (50) NULL,
[firstName] NVARCHAR (50) NULL,
[lastName] NVARCHAR (50) NULL,
[role] VARCHAR (10) NULL,
CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED ([ID] ASC)
);

INSERT INTO [dbo].[User] ([ID], [username], [firstName], [lastName], [role])


VALUES
(1, 'john_doe', 'John', 'Doe', 'admin'),
(2, 'jane_smith', 'Jane', 'Smith', 'user'),
(3, 'bob_jones', 'Bob', 'Jones', 'user');

-- bảng OrderOrder
CREATE TABLE [dbo].[Order] (
[id] INT IDENTITY (1, 1) NOT NULL,
[userId] INT NULL,
[status] VARCHAR (50) NOT NULL,
[total] DECIMAL (10, 2) NOT NULL,
PRIMARY KEY CLUSTERED ([id] ASC),
FOREIGN KEY ([userId]) REFERENCES [dbo].[User] ([ID])
);

INSERT INTO [dbo].[Order] ([userId], [status], [total])


VALUES
(1, 'pending', 799.99),
(2, 'completed', 39.99),
(3, 'pending', 19.99);

-- bảng OrderDetail
CREATE TABLE [dbo].[OrderDetail] (
[id] INT IDENTITY (1, 1) NOT NULL,
[idorder] INT NULL,
[idproduct] INT NULL,
[price] DECIMAL (10, 2) NOT NULL,
[quantity] INT NOT NULL,
PRIMARY KEY CLUSTERED ([id] ASC),
FOREIGN KEY ([idorder]) REFERENCES [dbo].[Order] ([id]),
FOREIGN KEY ([idproduct]) REFERENCES [dbo].[Product] ([id])
);

INSERT INTO [dbo].[OrderDetail] ([idorder], [idproduct], [price], [quantity])


VALUES
(1, 1, 799.99, 1),
(2, 3, 39.99, 1),
(3, 2, 19.99, 1);

-- Hiển thị dữ liệu từ bảng Category


SELECT * FROM [dbo].[Category];

-- Hiển thị dữ liệu từ bảng User


SELECT * FROM [dbo].[User];

-- Hiển thị dữ liệu từ bảng Product


SELECT * FROM [dbo].[Product];
-- Hiển thị dữ liệu từ bảng Order
SELECT * FROM [dbo].[Order];

-- Hiển thị dữ liệu từ bảng OrderDetail


SELECT * FROM [dbo].[OrderDetail];

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy