mysql database
OBJECTIVES
Taking a look at different data storage issues and basic table management.
II.ASSUMPTIONS
In this lab you will look at how the database stores tables for both the InnoDB and MyISAM storage engines. This information will be used in later labs. You will also look at various options available when creating tables and several different types of tables that MySQL supports.
III.PROCEDURE
Things to do prior to beginning your lab.
If you are using the EDUPE-VT environment then before you begin any lab work you will want to check the current status of your VM before trying to access it. If the VM is either suspended or halted it will be necessary to change the status to running. To do this you will need to log into EDUPE-VT VM Control Center (https://devry.edupe.net:9090/). First, you want to set your email notification. Now, use the STUDENT MAINTANCE_TOOLS - CHECK VM USAGE tool to check the status of the VM. If the VM is in a suspended status then use the VM_TOOLS - CONTROL VM tool to RESUME the VM. If the VM is in a halted status then use the VM_TOOLS - CONTROL VM tool to RESTART the VM.
Once your VM is in a state of “running” then you can go to the EDUPE-VT Remote Desktop Gateway (http://devry.edupe.net:8080/) and follow the instructions in the “Student Guide_Connecting to Your VM Remote VM Desktop” document found in Doc Sharing for accessing your VM).
For each lab it will be necessary for you to create an output file that will capture all of your commands and work within your MySQL session. Once you have successfully logged into your VM, follow the instructions in the “Student Guide_Creating an output script of your MySQL session” document that can be found in DocSharing.
NOTE: If you have to stop your lab session and then go back later you need to be sure that you are using the same file name for your output file. Doing so will allow MySQL to append the new work to the end of the file thus allowing you to save all of your lab output into one file. If you do end up using two or more file names then you will need to copy and paste the contents of the second file into the first and thus just have one file to turn in.
Review the lecture in Week 4 for additional information that can be used for this lab.
To begin this lab we want to reset our MySQL server back to the original state that we started with. At the Windows Command C:\> prompt execute the command to shut down the MySQL56 service. Now under the C:\ProgramData folder find the my.ini initialization file and change the default-storage-engine variable in the file to reflect an INNODB storage engine. Save the file and then go back to the Windows Command prompt and issue the command to start the MySQL56 service back up.
Now Startup your MySQL session from the Windows Command Line window using localhost as the host, the root user and “devrydevry” password. You also need to start your output file.
The two storage engines that we are dealing with in this class are the Innodb and MyISAM storage engine. It is important to understand how each handles table and data storage, so in this section we are going to first look at how this is done.
We will start with the INNODB storage engine. Using the SHOW VARIABLES command find variables that contain INNODB_DATA. You need to use the LIKE delimiter to return just those variables.
Now we need to look at log files. Using the SHOW VARIABLES command find variables that contain INNODB_LOG. Again, be sure to use the LIKE delimiter. Notice that the innodb_log_group_home_dir has a setting of ./. Include an entry in your iLab Report Conclusions section explaining what this means (you will probably need to do some research on the internet for this).
Now let’s look at the MYISAM engine and see what the differences are. Using the SHOW VARIABLES command again, find variables that contain MYISAM. Add an entry in your iLab Report Conclusions section addressing why the MYISAM engine does not have variables for data or log entries.
Now we are going to look at some basic table management in the MySQL database environment.
To begin with, set your session to use the devrydbm438 database. Now, create two tables, one named S_EMP and the other named S_DEPT, based on the following specifications and have them associated with the MyISAM storage engine. Remember that your MySQL session by default now uses the InnoDB storage engine so you will need to add the necessary definition to your create statements to have the two tables use the MyISAM storage engine.
Once you have successfully created the two tables use the SHOW TABLES command to list the tables currently in the devrydbm438 database.
The INFORMATION_SCHEMA.COLUMNS table contains columns that will allow you to show the table name, the column name, the data type and the columns that have constraints associated with them. Write and execute the query on this table that will show this data for each of the two tables.
Now we need to look at more specific information about the tables that were created. Using the TABLES table in INFORMATION_SCHEMA write and execute the query that will show the table name, the engine, the data length, the maximum data length and the auto incrimination setting for each table in the devrydbm438 database.
Sometimes it is necessary to create a WORK table based on the definition of an existing table. This is the same thing as creating an actual TEMPORARY TABLE, but in this case, it is a temporary table based on the definition of an existing permanent table. Obviously, you could use the CREATE TABLE script from the existing table, but this is not always available. To help overcome this problem, you can create a new table using a SELECT statement on the existing table as the subquery to the CREATE TABLE statement. If the existing table has data in it, you can either allow the data to transfer or you can exempt the data by adding a where clause like WHERE 1 = 2. The table gets created, only without the data.
For this part of the lab, you are going to create a new table based on the definition of the S_DEPT table. Before you do this, though, we want to put some data in the table. Download the DBM438_LOAD_DEPT.SQL file from Doc Sharing and run the script using the SOURCE command to load your S_DEPT table with four records.
Now, create a new TEMPORARY table named G_DEPT based on the S_DEPT table. Make sure that the data in S_DEPT gets transferred to the new table. After the table is created, query the new G_DEPT table to verify that the data is there.
Remember that this is only a work table, good for a single session. To compare this new type of table to the two that you have already created, query the INFORMATION_SCHEMA.COLUMNS table to show the table name, the column name, the data type for the G_DEPT table. What was in the result set of the query? Add an entry in your iLab Report Conclusions section addressing why this query returned the results it did.
Now we are going to go through the process of making changes to the two tables that have been created. Often time business requirements change and thus changes to the database follow. For this case the changes will be easy as there is no data in the tables as if there were the changes would be a little more involved. Let’s get started.
The S_DEPT table needs to be able to accommodate a picture of each location. The pictures are .gif format and will require the correct type of column data type to store the photo internally. Add a column to the S_DEPT table named LOCATION_PIC that will satisfy this requirement. Keep in mind that picture files are binary so you need to pic a data type that will accept a binary file.
The column name LOC is not very descriptive of the column contents and could cause some confusion. It has been decided to use the full description LOCATION for the column name. Write and execute the statement that will alter the DEPT table and rename the column LOC to LOCATION.
Additionally, some of the table’s locations are turning out to be longer names than the column will allow, and it was also decided that the data type needed to be a VARCHAR in place of a CHAR data type. Write and execute the required statement to change the column data type to a VARCHAR with a length of 30.
The department name column of the S_DEPT table contains the names of the departments per location. This column seems well suited for an index. Write and execute the statement that would create a new index for the DNAME column. Name the index LOC_IDX.
Now use the INFORMATION_SCHEMA.COLUMNS table to show the table name, the column name, the data type for the S_DEPT table. In addition, use the DESCRIBE command to look at the S_DEPT table.
Now use the SHOW INDEX command to show the indexes in the S_DEPT table.
This concludes your lab for this week. You will need to open the output file(s) for this lab on the S drive of your VM, copy the contents of the file and then paste them into the Lab Report document for this lab under the Lab Results section. If you will use Courier New 9pt. font formatting it will look just like in the session. This completes this lab.
11 years ago
20
- PSY 355 Week 3 Individual Assignment Motivation and the Brain Paper
- ACC 291 Week 3 Learning Team Learning Team Reflection
- Do absolute moral statements (e.g., "Thou shall not kill" [Exod 20:13]) work in every situation? Can there be exceptions to...
- couple assignments
- MGT 434 Week 1 Individual Assignment Legal Process Paper
- MAT 540 Quiz 3 100 Out of 100 A++++++++++++
- MGT 431 Week 4 Individual Assignment Incentive Plans Paper
- 200-101 Interconnecting Cisco Networking Devices 2 (ICND Part 2) Real Exam Questions, PDF and 3.4.2 VCE
- Article Critique
- <a href="http://imgur.com/gUSHLDd"><img src="http://i.imgur.com/gUSHLDd.jpg" title="source: imgur.com" /></a>