You are on page 1of 15

Aim: To create a table and insert some values to the given database schema

1.SELECT * FROM product_Team2;

DESC:
CREATE TABLE products_Team2 (
ProductID INT PRIMARY KEY AUTO_INCREMENT,
ProductSKU VARCHAR(50),
ProductName VARCHAR(255),
ProductPrice DECIMAL(10, 2),
ProductWeight DECIMAL(10, 2),
ProductCartDesc TEXT,
ProductShortDesc VARCHAR(255),
ProductLongDesc TEXT,
ProductThumb VARCHAR(255),
ProductImage VARCHAR(255),
ProductCategoryID INT,
ProductStock INT,
ProductLocation VARCHAR(255)
);
This SQL statement creates a table named products_Team2 with
several columns to store information about each product. Here's a
breakdown of the columns:
1. ProductID: Primary key of the table, uniquely identifying each
product. This column is set to auto-increment, ensuring each
product receives a unique identifier.
2. ProductSKU: The SKU (Stock Keeping Unit) of the product.
3. ProductName: The name of the product.
4. ProductPrice: The price of the product.
5. ProductWeight: The weight of the product.
6. ProductCartDesc: The description of the product as displayed in
the shopping cart. It is defined as a TEXT type to accommodate
larger descriptions.
7. ProductShortDesc: A short description of the product.
8. ProductLongDesc: A long description of the product. It is defined
as a TEXT type to accommodate larger descriptions.
9. ProductThumb: The filename of the thumbnail image associated
with the product.
10. ProductImage: The filename of the main image associated
with the product.
11. ProductCategoryID: The ID of the category to which the
product belongs. It represents a foreign key referencing the
productcategories_t25 table.
12. ProductStock: The stock quantity of the product.
13. ProductLocation: The location where the product is
stocked.
This query is inser ng data into the products_Team2 table, presumably for
an e-commerce system. Each row represents informa on about a specific
product, with columns describing various a ributes such as SKU, name,
price, descrip on, stock quan ty, etc.

2. SELECT * FROM orderdetails_Team2;

DESC:
CREATE TABLE orderdetails_Team2 (
DetailID INT PRIMARY KEY AUTO_INCREMENT,
DetailOrderID INT,
DetailProductID INT,
DetailName VARCHAR(255),
DetailPrice DECIMAL(10, 2),
DetailSKU VARCHAR(50),
DetailQuantity INT
);
This SQL statement creates a table named orderdetails_Team2 with
several columns to store details about each product in an order. Here's
a breakdown of the columns:
1. DetailID: Primary key of the table, uniquely identifying each order
detail. This column is set to auto-increment, ensuring each detail
receives a unique identifier.
2. DetailOrderID: The ID of the order to which the detail belongs. It
represents a foreign key referencing the orders table.
3. DetailProductID: The ID of the product associated with the detail.
It represents a foreign key referencing the products table.
4. DetailName: The name of the product.
5. DetailPrice: The price of the product.
6. DetailSKU: The SKU (Stock Keeping Unit) of the product.
7. DetailQuantity: The quantity of the product ordered.

3. SELECT * FROM productoptions_Team2;


DESC :
INSERT INTO productoptions_t25 (OptionID, ProductID, OptionGroupID,
OptionPriceIncrement)
VALUES
(1, 1, 1, 5.00),
(2, 1, 2, 0.00),
(3, 2, 1, 3.00);
This SQL statement creates a table named productoptions_t25 with four
columns:
1. OptionID: This column serves as the primary key for the table and
uniquely identifies each product option.
2. ProductID: This column stores the identifier of the product
associated with the option.
3. OptionGroupID: This column stores the identifier of the option group
to which the option belongs.
4. OptionPriceIncrement: This column stores the price increme
5. Copy code
6. INSERT INTO productoptions_t25 (OptionID, ProductID,
OptionGroupID, OptionPriceIncrement
Each row inserted includes values for the OptionID, ProductID,
OptionGroupID, and OptionPriceIncrement columns, as specified in the
INSERT statement. These values represent di erent product options
associated with specific products.
4. SELECT * FROM Productcategories_Team2;

DESC:
CREATE TABLE productcategories_Team2 (
CategoryID INT PRIMARY KEY AUTO_INCREMENT,
CategoryName VARCHAR(255) NOT NULL
);
1. This SQL statement creates a table named
productcategories_t25 with two columns:

2. CategoryID: This column serves as the primary key for the


table and is of type INT. It will automatically increment with
each new entry, ensuring a unique identifier for each
category.

3. CategoryName: This column stores the name of each


product category. It is of type VARCHAR(255) to
accommodate variable-length strings, and it's set to NOT
NULL, meaning it must have a value for each entry.
5.SELECT* FROM orders_Team2;

DESC:
CREATE TABLE orders_Team2 (
OrderID INT PRIMARY KEY AUTO_INCREMENT,
OrderUserID INT,
OrderAmount DECIMAL(10, 2),
OrderShipName VARCHAR(255),
OrderShipAddress VARCHAR(255),
OrderShipAddress2 VARCHAR(255),
OrderQty INT,
OrderState VARCHAR(100),
OrderZip VARCHAR(20),
OrderCountry VARCHAR(100),
OrderPhone VARCHAR(20),
OrderFax VARCHAR(20),
OrderShipping DECIMAL(10, 2),
OrderTax DECIMAL(10, 2),
OrderEmail VARCHAR(255),
OrderShipped TINYINT,
OrderTrackingNumber VARCHAR(50)
);

The table orders_Team2 is designed to store information about orders


placed by users. Below is a description of each column in the table:

1. OrderID: Primary key of the table, uniquely identifying each


order. This column is set to auto-increment, ensuring each
order receives a unique identifier.

2. OrderUserID: The ID of the user who placed the order. It


represents a foreign key referencing the users' table.

3. OrderAmount: The total amount of the order.

4. OrderShipName: The name of the person to whom the order is


being shipped.

5. OrderShipAddress: The primary address of the shipping


location.

6. OrderShipAddress2: Additional address information (e.g.,


apartment number, suite number).

7. OrderQty: The quantity of items ordered.

8. OrderState: The state or province of the shipping address.


9. OrderZip: The postal code or ZIP code of the shipping address.

10. OrderCountry: The country of the shipping address.

11. OrderPhone: The phone number associated with the order.

12. OrderFax: The fax number associated with the order.

13. OrderShipping: The shipping cost associated with the order.

14. OrderTax: The tax amount applied to the order.

15. OrderEmail: The email address associated with the order.

16. OrderShipped: Indicates whether the order has been


shipped. It is a boolean value (0 for not shipped, 1 for shipped).

17. OrderTrackingNumber: The tracking number associated


with the shipment.

This table structure allows for the storage of comprehensive


information about each order, including user details, shipping
information, order items, and financial aspects such as shipping
costs and taxes.
6.SELECT * FROM options_Team2;

DESC:
CREATE TABLE options_Team2 (
OptionID INT PRIMARY KEY AUTO_INCREMENT,
OptionName VARCHAR(255) NOT NULL
); This SQL statement creates a table named options_Team2 with two
columns:
1. OptionID: This column serves as the primary key for the table and is
of type INT. It will automatically increment with each new entry,
ensuring a unique identifier for each option.
2. OptionName: This column stores the name of each option. It is of
type VARCHAR(255) to accommodate variable-length strings, and
it's set to NOT NULL, meaning it must have a value for each entry.
7.SELECT * FROM optiongroups_Team2;

DESC:
CREATE TABLE optiongroups_Team2 (
OptionGroupID INT PRIMARY KEY AUTO_INCREMENT,
OptionGroupName VARCHAR(255) NOT NULL
);
This SQL statement creates a table named optiongroups_Team2 with two
columns:
1. OptionGroupID: This column serves as the primary key for the table
and is of type INT. It will automatically increment with each new
entry, ensuring a unique identifier for each option group.
2. OptionGroupName: This column stores the name of each option
group. It is of type VARCHAR(255) to accommodate variable-length
strings, and it's set to NOT NULL, meaning it must have a value for
each entry.
8.SELECT * FROM users_Team2;

DESC:
CREATE TABLE users_Team2 (
UserID INT PRIMARY KEY AUTO_INCREMENT,
UserEmail VARCHAR(255) NOT NULL,
UserPassword VARCHAR(255) NOT NULL,
UserFirstName VARCHAR(255),
UserLastName VARCHAR(255),
UserCity VARCHAR(255),
UserState VARCHAR(255),
UserZip VARCHAR(20),
UserEmailVerified TINYINT,
UserVerificationCode VARCHAR(255),
UserIP VARCHAR(255),
UserPhone VARCHAR(20),
UserFax VARCHAR(20),
UserCountry VARCHAR(255),
UserAddress VARCHAR(255),
UserAddress2 VARCHAR(255)
);

This SQL statement creates a table named users_Team2 with several


columns to store user information. Here's a breakdown of the columns:
1. UserID: Primary key of the table, uniquely identifying each user.
This column is set to auto-increment, ensuring each user
receives a unique identifier.
2. UserEmail: The email address of the user. It is marked as NOT
NULL to ensure all users have an associated email address.
3. UserPassword: The password of the user. It is marked as NOT
NULL for security reasons.
4. UserFirstName: The first name of the user.
5. UserLastName: The last name of the user.
6. UserCity: The city of the user's address.
7. UserState: The state or province of the user's address.
8. UserZip: The postal code or ZIP code of the user's address.
9. UserEmailVerified: Indicates whether the user's email address
has been verified (1 for verified, 0 for not verified).
10. UserVerificationCode: A code used for email verification.
UserIP: The IP address of the user.
11. UserPhone: The phone number associated with the user.
12. UserFax: The fax number associated with the user.
13. UserCountry: The country of the user's address.
14. UserAddress: The primary address of the user.
15. UserAddress2: Additional address information (e.g., apartment number,
suite number).

Conclusion:

 The tables and data provided serve as a foundation for managing


various aspects of a hypothetical e-commerce platform,
including products, orders, users, options, and option groups.
 The structured organization of data within the tables facilitates
e icient retrieval and manipulation of information.
 Properly defining relationships between tables enables the
establishment of data integrity and enhances query capabilities.
 Overall, these SQL statements demonstrate the initial setup and
population of a database schema tailored to the needs of an e-
commerce system.

You might also like