Fundemental of Databases
Fundemental of Databases
PRACTICAL SESSION 1
I. Setup enviroment
1. Install MySQL
The traditional way to install MySQL is to use the official installer provided at
https://dev.mysql.com/downloads/installer/. However, if you want to get phpMyAdmin
also (one of the most famous tools for administration of MySQL), you should instead use
some software bundles like XAMPP. You may be pleased to know that XAMPP supports
3 common OSs (Windows, Ubuntu, MacOS). When using XAMPP, to manage services,
let run the file xampp-control.exe in Windows, then make sure that the service MySQL is
running like the below figure. To invoke phpMyAdmin, let click the button Admin, then
you will be navigated to the address http://localhost/phpmyadmin/.
2. Connect to MySQL
MySQL is in fact a server side software which expose its services via a TCP-IP
connections. For each session working with MySQL, you have to provide host name (or
IP), port (the default is 3306), username, and password.
Command-line client
Mysql is a command-line client program that allows you to interact with MySQL in the
interactive and non-interactive mode. The mysql command-line client is typically located
in the bin directory of the MySQL’s installation folder. To invoke the mysql program,
you just simply navigate to the bin directory of the MySQL’s installation folder and type:
mysql
shell>mysql -u root -p
If everything is OK, you will connect to the MySQL Server with the following command:
mysql>
You can now run SQL statement by typing it and press enter. For example, to display the
databases, run:
Graphical tools
A more convenient way to work with MySQL server is to use graphical client tools. For
example, to connect to server with MySQL Workbench:
- Click “MySQL Connections” to go to the screeen “Setup New Connection”
- Enter the name of the new connection (to be displayed in the first screen), the
connection information (ip, port, username, password). Click “Test Connection”
to check if the connection works well, then click OK to save the new connection.
- From the Home screen, click the connection you defined in the previous step
- Once connected, you work with the server by writing SQL statements, in the
query panel. To run a single statement, just select it, and press “Ctrl + Enter” or
4. Add column Partner_ssn to the table EMPLOYEE. This column indicates the
SSN of spouse of each employee. For those who are now single, the value should
be NULL.
5. Write SQL statements to insert sample rows to these tables.
6. Write SQL statements to delete the tables you created.