DB LAB Week 5
DB LAB Week 5
Week # 5:
Introduction to MYSQL Workbench tool
Introduction of command Prompt and it’s complete use
with MYSQL. Introduction to SQL (DDL) Create
database, show database, create table
Adding constraint in create table (e.g. default, unique,
foreign key (cascade), primary key, not null) Drop
database Desc table (description) Drop table.
Objectives: The objective of this lab is to learn and write SQL DDL statements.
Outcomes: After completing this Lab, students are expected to be able to write SQL DDL
statements of any case study.
Create a database “Company” on MySQL workbench tool and perform the following actions:
Create a Table “Employee”.
Insert the Columns “EmpID, EmpName, EmpAge, EmpDept” with Datatypes
“INT, VARCHAR(60), INT, VARCHAR(45)”.
Set “EmpID” as “Primary Key”.
Add constrain that all columns values of table should be “Not Null”.
Insert record/values of 4 employees in above created table Employee as given
below:
Build a database named ‘CarRentalDB’ using given ERD and perform the following task.
Make a table for each database relation and list the attributes with types. Make
sure you know the reason why you chose the type of data.
Define the primary key for each relation. Make sure the primary key identifies
each tuple uniquely.
What are the foreign key constraints that should be included when creating the
tables in the CarRentalDB database in the following figure?
Write the appropriate DDL statement to create, describe, delete and drop
database and tables.