Act 2
Act 2
Duque
Course&year: BSINTE2B
Instruction: Please follow the instructions below. Then give the SQL commands and values.
Please use this document to place your answers.
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
2. Create the following table in database:db_pie
Tablename: Categories
Fieldname datatype other attributes
CategoryID int
CategoryName varchar(15)
Description varchar(50)
mysql> USE db_pie
Database changed
mysql> Create Table Categories(CategoryID int PRIMARY KEY,
-> CategoryName varchar(15),
-> Description varchar(50));
Query OK, 0 rows affected (0.03 sec)
Tablename: Customers
Fieldname datatype other attributes
CustomerID char(5)
CompanyName varchar(40)
ContactName varchar(30)
ContactTitle varchar(30)
Address varchar(60)
City varchar(15)
Region varchar(24)
mysql> CREATE TABLE Customers(
-> CusromerID char(5) Primary KEY,
-> CompanyName varchar(40),
-> ContactName varchar(30),
-> ContactTitle varchar(30),
-> Address varchar(60),
-> City varchar(15),
-> Region varchar(24));
Query OK, 0 rows affected (0.03 sec)
Tablename: Employees
Fieldname datatype other attributes
Lastname varchar(20)
Firstname varchar(10)
Title varchar(30)
Birthdate datetime
Hiredate datetime
Address varchar(60)
City varchar(15)
Region varchar(15)
Country varchar(15)
ReportsTo int
mysql> CREATE TABLE Employees(
-> Lastname varchar(20),
-> Firstname varchar(10
-> ),
-> Title varchar(30),
-> Birthdate datetime,
-> Hiredate datetime,
-> Address varchar(60),
-> City varchar(15),
-> Region varchar(15),
-> Country varchar(15),
-> ReportsTo int);
Query OK, 0 rows affected (0.03 sec)
Tablename: Shippers
Fieldname datatype other attributes
ShipperID int
ComapnyName varchar(40)
Phone varchar(24)
mysql> CREATE TABLE Shippers(
-> ShipperID int PRIMARY KEY,
-> CompanyName varchar(40),
-> Phone varchar(24));
Query OK, 0 rows affected (0.03 sec)
Tablename: Branch
Fieldname datatype other attributes
BranchID int
Location varchar(50)
EmployeeID varchar(30)
ContactNumber varchar(15)
mysql> create table Branch(BranchID int,
-> Location varchar(50),
-> EmployeeID varchar(50),
-> ContactNumber varchar(15));
Query OK, 0 rows affected (0.02 sec)
9. Modify the following tables using other DDL (e.g. UPDATE, ALTER, DROP) commands
Database: db_pie
Tablename: Suppliers
Operation: Modify the following columns/fields.
Fieldname Fieldname Datatype
ContactName to ContactName varchar(25)
Fax to FaxNumber varchar(24)
mysql> ALTER TABLE suppliers
-> change ContactName ContactName varchar(25);
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
11. Modify the following tables using other DDL (e.g. UPDATE, ALTER, DROP) commands
Database: db_school
Tablename: Faculty
Operation: Add the following columns/fields.
Fieldname datatype
Hireddate datetime
mysql> ALTER TABLE faculty
-> ADD HiredDate datetime;
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
Tablename: Department
Fieldname datatype other attributes
DepartmentID varchar(15)
Description varchar(50)
mysql> create table Department(DepartmentID varchar(15),
-> Description varchar(50));
Query OK, 0 rows affected (0.00 sec)
13. Modify the following tables using other DDL (e.g. UPDATE, ALTER, DROP) commands
Database: db_school
Tablename: Faculty
Operation: Modify the following columns/fields.
Fieldname Fieldname Datatype
Department to DepartmentID varchar(15)
mysql> use db_school;
Database changed
mysql> ALTER TABLE Faculty
-> change Department DepartmentID varchar(15);
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
17. Modify the following tables using other DDL (e.g. UPDATE, ALTER, DROP) commands
Database: db_pie
Tablename: tbl_users
Operation: Modify the following columns/fields.
Fieldname Fieldname Datatype
UMiddleInitial to UMiddleName varchar(25)
mysql> use db_pie;
Database changed
mysql> Alter table tbl_users
-> change UMiddleInitial UMiddleName varchar(25);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
Database: db_pisoc
Tablename: tbl_users
Operation: Modify the following columns/fields.
Fieldname Fieldname Datatype
UMiddleInitial to UMiddleName varchar(25)
mysql> use db_pisoc;
Database changed
mysql> Alter Table tbl_users
-> change UMiddleInitial UMiddleName varchar(25);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
Database: db_school
Tablename: tbl_users
Operation: Modify the following columns/fields.
Fieldname Fieldname Datatype
UMiddleInitial to UMiddleName varchar(25)
mysql> use db_school;
Database changed
mysql> Alter TABLE tbl_users
-> change UMiddleInitial UMiddleName varchar(25);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
18. Modify the following tables using other DDL (e.g. UPDATE, ALTER, DROP) commands
Database: db_pisoc
Tablename: Carrier
Operation: Add the following columns/fields.
Fieldname datatype
Branches varchar(25)
DateEstablished datetime
mysql> use db_pisoc;
Database changed
mysql> ALTER TABLE Carrier
-> ADD COLUMN Branches varchar(25);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
Database: db_school
Tablename: Faculty
Operation: Add the following columns/fields.
Fieldname datatype
Sex varchar(6)
Religion varchar(25)
BirthDate Datetime
mysql> ALTER TABLE Faculty
-> ADD COLUMN Sex varchar(6);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
19. Modify the following tables using other DDL (e.g. UPDATE, ALTER, DROP) commands
Operation: Modify the following tables
Database: db_pie
Tablename Tablename
tbl_users to PIEUsers
mysql> use db_pie;
Database changed
mysql> RENAME TABLE tbl_users TO PIEUsers;
Query OK, 0 rows affected (0.02 sec)
Database: db_school
Tablename Tablename
tbl_users to SchoolUsers
mysql> use db_school;
Database changed
mysql> RENAME TABLE tbl_users TO SchoolUsers;
Query OK, 0 rows affected (0.00 sec)
Database: db_pisoc
Tablename Tablename
tbl_users to PisocUsers
mysql> use db_pisoc;
Database changed
mysql> RENAME TABLE tbl_users TO PisocUsers;
Query OK, 0 rows affected (0.00 sec)
Tablename:Staff
Fieldname datatype other attributes
*the same fieldname and datatypes of database: db_pie table: Employees
mysql> use db_school;
Database changed
mysql> Create table Staff(Lastname varchar(20),
-> Firstname varchar(10),
-> Title varchar(30),
-> Birthdate datetime,
-> Hiredate datetime,
-> Address varchar(60),
-> City varchar(15),
-> Region varchar(15),
-> Country varchar(15),
-> ReportsTo int(11));
Query OK, 0 rows affected (0.02 sec)
21. Modify the following tables using other DDL (e.g. UPDATE, ALTER, DROP) commands
Database: db_school
Tablename: Staff
Operation: Add the following columns/fields.
Fieldname datatype
BloodType varchar(5)
Nationality varchar(25)
ContactNumber varchar(15)
mysql> use db_school;
Database changed
Database: db_pisoc
Tablename: Branch
Operation: Modify the following columns/fields.
Fieldname Fieldname Datatype
EmployeeID to StaffID varchar(8)
mysql> use db_pisoc;
Database changed
mysql> ALTER TABLE Branch
-> Change EmployeeID StaffID varchar(8);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
Database: db_pie
Tablename: Employees
Operation: Add the following columns/fields.
Fieldname datatype
EmployeeID varchar(8)
mysql> use db_pie;
Database changed
mysql> ALTER TABLE Employees
-> ADD EmployeeID varchar(8);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
Database: db_school
Tablename: Staff
Operation: Add the following columns/fields.
Fieldname datatype
StaffID varchar(8)
Tablename:Personnel
Fieldname datatype other attributes
*the same fieldname and datatypes of database: db_school table: Staff
*included all the changes made
mysql> use db_pisoc;
Database changed
Tablename:Courses
Fieldname datatype other attributes
CourseID varchar(10)
Description varchar(100)
LastRevised Datetime
CurriculumNo varchar(10)
24. Modify the following tables using other DDL (e.g. UPDATE, ALTER, DROP) commands
Database: db_pie
Tablename Tablename
Categories tbl_Categories
Customers tbl_Customers
Employees tbl_Employees
Suppliers tbl_Suppliers
PIEUsers tbl_PIEUsers
mysql> use db_pie;
Database changed
mysql> RENAME TABLE Categories TO tbl_categories;
Query OK, 0 rows affected (0.02 sec)
Database: db_pisoc
Tablename Tablename
Products tbl_Products
OrderDetails tbl_OrderDetails
Shippers tbl_Shippers
Carrier tbl_Carrier
Branch tbl_Branch
Personnel tbl_Personnel
PisocUsers tbl_PisocUsers
Database: db_school
Tablename Tablename
Faculty tbl_Faculty
Student tbl_Student
Subject tbl_Subject
Department tbl_Department
Staff tbl_Staff
Courses tbl_Courses
SchoolUsers tbl_SchoolUsers
Tablename: tbl_Church
Fieldname datatype other attributes
ChurchID int
mysql> create table tbl_Church(ChurchID int);
Query OK, 0 rows affected (0.00 sec)
Tablename: tbl_Activities
Fieldname datatype other attributes
ActivityID int
mysql> create table tbl_Activities(ActivityID int);
Query OK, 0 rows affected (0.01 sec)
26. Modify the following tables using other DDL (e.g. UPDATE, ALTER, DROP) commands
DatabaseName: db_pie
Tablename: tbl_Employees
Operation: Modify the following columns/fields.
Fieldname Fieldname Datatype
Address to Address varchar(60)
Title to Position varchar(30)
ReportsTo to Supervisor varchar(25)
mysql> use db_pie;
Database changed
mysql> ALTER TABLE tbl_Employees
-> Change Address Address varchar(60);
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
DatabaseName: db_pis
Tablename: tbl_Baptism
Operation: Modify the following columns/fields.
Fieldname Fieldname Datatype
ID to BaptismID int
mysql> use db_pis;
Database changed
mysql> ALTER TABLE tbl_Baptism
-> Change ID BaptismID int;
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
DatabaseName: db_pis
Tablename: tbl_Baptism
Operation: Add the following columns/fields.
Fieldname datatype other attributes
FirstName varchar(25)
MiddleName varchar(25)
LastName varchar(25)
Age int
BirthDate Datetime
mysql> ALTER TABLE tbl_Baptism
-> ADD COLUMN FirstName varchar(25);
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
DatabaseName: db_pisoc
Tablename: tbl_Shippers
Operation: Modify the following columns/fields.
Fieldname Fieldname Datatype
Phone to ContactNumber varchar(12)
ComapnyName to CompanyName varchar(30)
mysql> use db_pisoc;
Database changed
mysql> ALTER TABLE tbl_Shippers
-> Change Phone ContactNumber varchar(12);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
DatabaseName: db_pis
Tablename: tbl_Activities
Operation: Add the following columns/fields.
Fieldname datatype other attributes
Title varchar(100)
Venue varchar(20)
Schedule DateTime
RegistrationFee decimal(10,2)
Participants varchar(20)
Nature varchar(50)
Remarks varchar(30)
mysql> use db_pis;
Database changed
mysql> ALTER TABLE tbl_Activities
-> ADD COLUMN Title varchar(100);
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
27. Identify/Describe all the tables and other attributes(if any) of the following database.
*Note: You can copy your answers from your mysql command line by using copy and paste
operation.
DatabaseName: db_pie
DatabaseName: db_pisoc
DatabaseName: db_school
DatabaseName: db_pis
mysql> use db_pie;
Database changed
mysql> show tables;
+------------------+
| Tables_in_db_pie |
+------------------+
| tbl_categories |
| tbl_customers |
| tbl_employees |
| tbl_pieusers |
| tbl_suppliers |
+------------------+
5 rows in set (0.00 sec)
28. Identify/Describe all the fieldnames, datatype and other attributes(if any) of the following
database and tables.
*Note: You can copy your answers from your mysql command line by using copy and
paste operation.
2. How many tables do you have on database: db_pie, db_pisoc, db_school, db_pis,
db_ford
Answers:
DatabaseName No.of Tables
db_pie ???
db_pisoc ???
db_school ???
db_pis ???
db_ford ???
Answers:
Databases No of Tables
db_pie 5
db_pisoc 7
db_school 7
db_pis 3
db_ford 0 /Empty Set
SQL Commands:
DatabaseName SQL Commands
db_pie ???
db_pisoc ???
db_school ???
db_pis ???
db_ford ???
SQL Commands:
Databases SQLCommands
db_pie mysql> use db_pie;
mysql> show tables;
Commands