0% found this document useful (0 votes)
21 views5 pages

Fundemental of Databases

**Installing SQL Server and Running Basic SQL Commands** 1. **Installing SQL Server:** - Download the SQL Server installation package from the official Microsoft website. - Run the installer and follow the on-screen instructions. - Choose the appropriate installation type (e.g., Basic, Custom) based on your needs. - Configure the server settings, such as authentication mode and server roles. - Complete the installation and restart your computer if necessary. 2. **Running Basic S

Uploaded by

phamtheminh2409
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views5 pages

Fundemental of Databases

**Installing SQL Server and Running Basic SQL Commands** 1. **Installing SQL Server:** - Download the SQL Server installation package from the official Microsoft website. - Run the installer and follow the on-screen instructions. - Choose the appropriate installation type (e.g., Basic, Custom) based on your needs. - Configure the server settings, such as authentication mode and server roles. - Complete the installation and restart your computer if necessary. 2. **Running Basic S

Uploaded by

phamtheminh2409
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

FUNDAMENTALS 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.

There are multiple existing tools to connect to MySQL: command-line tool,


phpMyAdmin, MySQL Workbench, Visual Studio Code with plugin.

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

To connect to the MySQL Server, you use this command:

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:

mysql> show databases;

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

click button on the tool box.


II. Getting started with SQL statements
1. Write a SQL statement to create a new database name “Company”.
2. Write a SQL statement to create to set the default working database to
“Company”.
3. Write SQL statements to define tables of “Company” databases with contraints
and columns illustrated by igures below. You should determine appropriate
datatype for each column.

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.

You might also like