DEV Community

Gauraw Meherkhamb
Gauraw Meherkhamb

Posted on

Create Your First SQL Project: Adding a Customer Table to an E-Commerce Database

Resources:

MySQL Workbench (mysql.com/products/workbench)

MySQL documentation on CREATE TABLE statement (dev.mysql.com/doc/refman/8.0/en/create-tabl..)

MySQL documentation on INSERT statement (dev.mysql.com/doc/refman/8.0/en/insert.html)

Guide:

Connect to the database using MySQL Workbench and select the appropriate schema.

Create a new table named "customers" with the following columns:

customer_id (primary key, auto-increment)

first_name (varchar(255))

last_name (varchar(255))

email (varchar(255))

password (varchar(255))

address (varchar(255))

city (varchar(255))

state (varchar(255))

zip_code (varchar(255))

Use the following SQL statement:

CREATE TABLE customers ( customer_id INT AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR(255), last_name VARCHAR(255), email VARCHAR(255), password VARCHAR(255), address VARCHAR(255), city VARCHAR(255), state VARCHAR(255), zip_code VARCHAR(255) );

Insert sample data into the customers table using the INSERT statement. For example:
INSERT INTO customers (first_name, last_name, email, password, address, city, state, zip_code) VALUES ('John', 'Doe', 'johndoe@example.com', 'password123', '123 Main St', 'New York', 'NY', '10001');

Test the table by querying it using the SELECT statement. For example:
SELECT * FROM customers;

Once the table is working correctly, commit the changes to the database.
Congratulations, you have successfully added a customer table to the e-commerce database!

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay