Practical WK 6
Practical WK 6
Teacher will discuss this and provide feedback on your work from last week…
Part B: SQL
Creating tables and Inserting records using SQL
PS: you will have to download the SQL (MySQL Workbench) software on your own laptops to work more
efficiently.
Type the SQL command: SELECT * FROM tablename to check what is in each table
Now create a query that will list all the records in each of the tables.
List all the song records for those not published in 1982
List all the Albums that are ‘Thriller’.
Part C: SQL
1. Produce the following tables using the CREATE TABLE SQL statement.
CREATE TABLE Department (
depId char(1) PRIMARY KEY,
depName varchar(30)
);
2. We now enter some records to the tables. The INSERT statement is used to add
records to tables. Because the Employee contains a foreign key referencing the
table Department, we need to first add data to table Department
INSERT INTO Department VALUES ('G', 'general');
INSERT INTO Department VALUES ('H', 'hardware');
3. The SELECT statement is used to retrieve records from tables: create a SELECT
statement to display all records in the Employee table.
SELECT * FROM Employee;
4. Your turn to finish filling the tables so that you have about 4 records in each
table.
a. Add 3 more records to the Employee table using the fName 'David' for at
least one record.
b. Retrieve the fName and lName for all records for those employees with
an fName value of 'David'.
c. List all the employees who work in department ‘H’.
5. Use the INSERT statement to add the following record to the Employee table:
INSERT INTO Employee VALUES (102, 'Wang', 'Sam', 'H');
6. How would you add a new column (attribute) for employee contact in the table
employee? Do this as SQL statement.
7. In the employee table, we need to change the name ‘John’ to ‘Johnson’. Apply
this change via an SQL statement.
8. Remove Sally’s record from the table.
Save all your work along with screenshots for each question and answer including the
results table.