[go: up one dir, main page]

0% found this document useful (0 votes)
19 views2 pages

SQL Test

The document outlines the creation of four database tables: 'users', 'products', 'orders', and 'order_items', along with sample data for each table. The 'users' table includes user details, the 'products' table lists product information, the 'orders' table records user orders, and the 'order_items' table links orders to specific products with quantities. This structure supports a basic e-commerce system.

Uploaded by

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

SQL Test

The document outlines the creation of four database tables: 'users', 'products', 'orders', and 'order_items', along with sample data for each table. The 'users' table includes user details, the 'products' table lists product information, the 'orders' table records user orders, and the 'order_items' table links orders to specific products with quantities. This structure supports a basic e-commerce system.

Uploaded by

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

-- Create the "users" table

CREATE TABLE users (


id INT PRIMARY KEY,
fullname VARCHAR(100),
email VARCHAR(100),
created_at DATETIME,
Country CHAR(2)
);

-- Insert sample data into the "users" table


INSERT INTO users (id, fullname, email, created_at, Country)
VALUES
(1, 'John Doe', 'john.doe@example.com', '2023-08-01', 'US'),
(2, 'Jane Smith', 'jane.smith@example.com', '2023-08-02', 'US'),
(3, 'Timothée Lecomte', 'timothee.lecomte@example.com', '2023-08-03', 'FR'),
(4, 'Luca Rossi', 'luca.rossi@example.com', '2023-08-04', 'IT'),
(5, 'María García', 'maria.garcia@example.com', '2023-08-05', 'ES');

-- Create the "products" table


CREATE TABLE products (
id INT PRIMARY KEY,
product_type INT,
name VARCHAR(100),
price DECIMAL(6, 2)
);

-- Insert sample data into the "products" table


INSERT INTO products (id, product_type, name, price)
VALUES
(1, 1, 'Product A', 100.00),
(2, 1, 'Product B', 75.50),
(3, 2, 'Product C', 50.25);

-- Create the "orders" table


CREATE TABLE orders (
id INT PRIMARY KEY,
user_id INT,
created_at DATETIME
);

-- Insert sample data into the "orders" table


INSERT INTO orders (id, user_id, created_at)
VALUES
(1001, 1, '2023-08-01 10:00:00'),
(1002, 1, '2023-08-02 11:00:00'),
(1003, 2, '2023-08-03 12:00:00'),
(1004, 3, '2023-08-04 13:00:00'),
(1005, 4, '2023-08-05 14:00:00'),
(1006, 5, '2023-08-06 15:00:00');

-- Create the "order_items" table


CREATE TABLE order_items (
order_id INT,
product_id INT,
quantity INT
);

-- Insert sample data into the "order_items" table


INSERT INTO order_items (order_id, product_id, quantity)
VALUES
(1001, 1, 2),
(1002, 2, 1),
(1003, 3, 3),
(1004, 1, 1),
(1004, 3, 2),
(1005, 2, 4),
(1006, 1, 3),
(1006, 3, 1);

You might also like