Assignment7 SaurabhSinha
Assignment7 SaurabhSinha
We are going to use MariaDB (command prompt) for this Lab Assignment. Create a Word document
named Lab9.docx
Steps:
Type in CREATE DATABASE Lab9LastName; *LastName should be your last name such
as Lab9Heiden (for me).
To verify the database is created type SHOW DATABASES;
Provide SCREENSHOT 1 of the results (in Word document)
3) Set lab9heiden as current database by typing USE DATABASE lab9heiden;
Type in CREATE TABLE movie (ID int, ReleaseYear int, Title varchar(255), OriginEthnicity
varchar(255), Director varchar(255), PRIMARY KEY (ID));
Then type in show tables; to confirm the creation of the table.
Then type in describe movie; to confirm the fields are created properly.
Provide SCREENSHOT 2 of the results (in Word document)
5) Let’s download the data.
Now load it into the data directory. You can copy it to the file – if it is on Microsoft Windows it may be in
the C:\Program Files\MariaDB 10.6\data . Specifically, there should be a folder for your database –
lab9heiden.
6) Load the data into the table “movie”
Now type LOAD DATA INFILE 'wiki_movie.csv' IGNORE INTO TABLE movie COLUMNS
TERMINATED BY ',';
Now let’s get a count of the records in the table by typing in select count(*) from movie;
Provide SCREENSHOT 3 of the results (in Word document)
7) Count how many records have the word and in the title using the LIKE operator looking for a
movie title with face in it.
Type in the following: select ID, ReleaseYear, Title, OriginEthnicity, Director from movie where
title like '%face%';
Provide SCREENSHOT 5 of the results (in Word document)
9) Again write a query to count the records with the word face in the title and mention the server time
it takes for the query without index to run.
Type in: select count(*) from movie where title like '%face%';
Provide SCREENSHOT 6 of the results (in Word document)
10) Add an index on the title field that will help increase results time.
11) Use the index to see the results of using an index instead of a full table search with the count(*).
Type in the following: select ID, ReleaseYear, Title, OriginEthnicity, Director FROM movie WHERE
title like '%face%';
Provide SCREENSHOT 9 of the results (in Word document)