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

(M8 Hands-On) Activity - BSVZamora

The document outlines a hands-on activity for students to learn SQL data definition by creating databases and tables. Students will create 'Customers', 'Products', and 'Vendors' tables, set primary and foreign keys, and ensure appropriate data types and NOT NULL constraints. The final step involves running the queries and uploading them to a designated platform.

Uploaded by

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

(M8 Hands-On) Activity - BSVZamora

The document outlines a hands-on activity for students to learn SQL data definition by creating databases and tables. Students will create 'Customers', 'Products', and 'Vendors' tables, set primary and foreign keys, and ensure appropriate data types and NOT NULL constraints. The final step involves running the queries and uploading them to a designated platform.

Uploaded by

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

Hands-on Activity

SQL Data Definition


Objectives:

At the end of the exercise, the students should be able to:

▪ Create database and tables; and


▪ Set the primary key and foreign key of tables.

Procedure:
1. Create queries to perform the next steps.
2. Create the tables named Customers and Product. Set the appropriate data types and determines
which ones are supposed to be NOT NULL.
Customers: CustomerID (Primary key), FirstName, LastName, Email, Gender, Birthdate
Products: ProductID (Primary key), Description, Quantity, Price, VendorID
3. Create another table named Vendors with columns: VendorID (Primary key), Name, ContactNum,
CityAddress.
4. Set VendorID from the Vendor table as a foreign key in the Products table.

5. Click the Run button on the uppler left


6. Save a copy of your queries and upload it to canvas
CREATE TABLE Customers (
CustomerID INT PRIMARY KEY,
FirstName VARCHAR(50) NOT NULL,
LastName VARCHAR(50) NOT NULL,
Email VARCHAR(100) NOT NULL,
Gender CHAR(1) NOT NULL,
Birthdate DATE NOT NULL
);

CREATE TABLE Products (


ProductID INT PRIMARY KEY,
Description VARCHAR(255) NOT NULL,
Quantity INT NOT NULL,
Price DECIMAL(10, 2) NOT NULL,
VendorID INT
);

CREATE TABLE Vendors (


VendorID INT PRIMARY KEY,
Name VARCHAR(100) NOT NULL,
ContactNum VARCHAR(20) NOT NULL,
CityAddress VARCHAR(100) NOT NULL
);

ALTER TABLE Products


ADD CONSTRAINT FK_VendorID FOREIGN KEY (VendorID) REFERENCES Vendors(VendorID);

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