Lab#2
Lab#2
Part I
1. Use the syntax from the discussion to populate each table with 5 entries each.
drivers
vehicles:
3. Display only the ID, First Name, and Last name of the drivers.
4. Display the car makers and the car models in the vehicles table.
5. Show the screenshot of each set of results with your observation below each in Section 6 Database
Output.
Drivers:
Vehicles:
Part II
1. Use the UPDATE command to change a row value (ex. First Name, age) in each table.
Vehicles:
Part III
1. Delete one row from each table.
2. Show the screenshot of the newly updated tables with your observation below each in Section 6
Database Output.
Note: Do not drop the database or any tables.
Drivers:
Vehicles:
Part IV
1. Insert two rows to the drivers table with only age and address.
6. Add a new column in drivers called license_number with data type char(13)
10. Take a screenshot of the code snippets of resulting tables from SELECT commands with your
observation below each in Section 6 Database Output.
SELECT first_name, last_name FROM drivers;
Supplementary Activity
Questions
1. What happens if you insert an exact duplicate of any record that is already in your current database
table?
Ex. > INSERT INTO drivers VALUES(1,"James","Nicolas",20,"5 Peace St. QC",3,true);
> INSERT INTO drivers VALUES(1,"James","Nichelistine",20,"5 Peace St. QC",3,true)
You can try the result. Is the output allowable in a real environment? Why do you think the output was what
you saw?
- It duplicates but it is har to manage the database.
2. Given that you ran your SQL Command in the example in Question 1.
What happens if you try to delete one of the rows with the redundant id? (Ex. DELETE FROM drivers
WHERE id=1;) What do you think should the solution be against this kind of problem?
- The data with an id=1 will be deleted.
3. In Part IV of the Procedure section, what do you think is the difference between using an equals sign and
the is keyword when checking for NULL?
- The equal signs needed to use only for the identified value and “is” is for words or phrases.
Additional Reference: https://dev.mysql.com/doc/refman/8.0/en/working-with-null.html
4. Following from the part IV tasks where you’ve added a new column called license_number. What would
happen if you inserted "N014-123-M012XD3"? Why do you think that was the output?
- One of the rows will have "N014-123-M012XD3" in the license_number column.
5. Why is it necessary to introduce a WHERE clause when updating and deleting data?
- It’s because WHERE clause identify the data if it’s needed to be update or delete.
Conclusion:
I conclude in this lab activity that I’ve learned such as how to use UPDATE, DELETE, INSERT INTO,
ALTER, etc.