Getting Started With SQL
Tags: sql, programming, mysql, beginners
Published: 2023-03-18 07:48:04

SQL is an acronym for Standard Query Language. It is a language used in the management of databases within software packages. A **database** is a group of records logically related to one another and stored electronically on a computer. SQL is used to run efficient queries to derive insight and manage databases differently. A **DBMS** which stands for database management system is a software package used for managing and manipulating databases efficiently, these are done with the standard query language, SQL. There are different database management systems including Microsoft Access, MongoDB, MySQL, PostgreSQL, and so on. In this series, we’ll be using MySQL to learn commands in SQL and how to run some efficient queries.

## How to install MySQL
To run SQl on your personal computer, you’ll need to install 2 software.

- MySQL community server
You can download it through this [link](https://dev.mysql.com/downloads/mysql/)

- MySQL Workbench 
You can download it through this [link](https://downloads.mysql.com/archives/workbench/)

**NOTE:**

1. Install and set up the community server first. 
2. The earliest version of MySQL workbench has some issues on Mac so you can install an older version.
3. Remember the password you used when setting up MySQL, you’ll need it to access your databases.

After installing the MySQL community server and MySQL Workbench. You can open the workbench, you’ll see a database and a page that looks like this:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xd6h8554iefvdwzfun34.png)
You can click the existing connection or create a new connection clicking the (+) symbol next to “MySQL Connections”.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08g3tzpbjcsy2x610ruy.png)
You can name your new connection, then click ok.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aqp75y25d8pl7jqgxx8r.png)
Once the new connection has shown, you and click on it. A password request will show up and you can use the registered password you set when installing the package.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1xxyn54pi57jgcuoti72.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5m5rqc3snx88u2wpp7cm.png)

## Creating a new schema in MySQL

A schema in a database describes how tables are related and connected to one another. When you click the dropdown arrow in schema, you’ll see functions, tables, views and stored procedures.
To create a new schema, right click on the section labeled schemas and click ‘create schema’.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gcwmlhy0m34jwo1jajj7.png)
You can add a name to the new schema created and click apply.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ok4z0cab4cn54dzieyjm.png)


After doing this, refresh your schema’s page if it doesn’t show up, or restart the application.

## Creating a new table in MySQL

To create a table in sql, you can click the dropdown arrow on the newly created schema and right click on tables and click create table.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pe2e2kttka1hu50jlioa.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpuijniasez650nrqkb3.png)

Name your table and you can add columns by clicking under the column where ’click to edit’ is written. You can create a primary key by clicking the box under ‘pk’ and ‘nn’ standing for not null. The datatype can also be changed to either int, char and so on.
I named my table employee table and created a column named ‘empid’(Employee ID), which I made to be the primary key.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pg5964pvn9baee3rer8v.png)

Lets add more columns named ,Emp name(Employee Name),Emp dept(Employee Department) ,and Emp salary(Employee Salary).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/22r4nqmwwo8y61fclyhv.png)

After creating your columns you click apply.When you do, you’ll see a box which shows a possible SQL command you could write to do this automatically.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0g009y577bkd92shru64.png)

Click apply and you’ll see the new table under tables.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ltow1qrwd1v45jbzq5qh.png)
You can insert values into the table with the Insert Into syntax.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o6fo0f0qw55i55gd6xs3.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s5tchnj2uczb75ee4hvb.png)


We will see more on how to use syntax like this in the coming articles.
You can click the table icon next to employee table to display the table after running the command.

## Importing table in MySQL

While using SQL ,sometimes you’ll need to manage existing tables stored on some other part of the computer in the database, you can import those documents following these steps.

First, right-click the label ‘Tables’ under the new schema and select ‘table data import wizard’.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x234ug7ccbrct37rza2i.png)

Then you browse or locate the csv file you want to load.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9uf09bz0meqni83pr0hk.png)

Then you click next, till the table is successfully imported.
You can then refresh your schema and click on table and select it.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sgnreovtv8ooj5x798lg.png)


Hope you enjoyed this article, thanks for reading, please like, share and comment your thoughts.