Introduction to Structured Query Language(SQL)

Vasu Devan S
4 min readJan 29, 2022

--

What is SQL?

Structured Query Language (SQL) is used to communicate with a database.it is the standard language for relational database management systems. SQL statements are used to perform tasks such as updating data on a database or retrieving data from a database.

Basic Commands of SQL

◼Data Definition Language: It is used to Create or Modify the Structure of Database Objects. Ex:*Create, *Drop,*Alter.

◼Data Manipulation Language: It is used to manipulate data like Inserting, Deleting, and Updating. Ex: *Insert, *Update, *Delete.

◼Data Control Language: It deals with providing permission or access to the Database. Ex: *Grant, *Revoke.

What Is a Database?

A database is an organized collection of structured information, or data, typically stored electronically in a computer system. A database is usually controlled by a Database Management System(DBMS). Together, the data and the DBMS, along with the applications that are associated with them, are referred to as a database system, often shortened to a just database.

Data within the most common types of databases in operation today is typically modeled in rows and columns in a series of tables to make processing and data querying efficient. The data can then be easily accessed, managed, modified, updated, controlled, and organized. Most databases use structured query language (SQL) for writing and querying data.

Why do we need a Database?

Since we are in the 21st Century, Everything around us is data, as there is a drastic growth in electrical gadgets, and also the interaction of Machine learning and Artificial Intelligence in gadgets, Every device generates data tons of data every second all around the World. To use the data we need a Database. A database is a way of storing information in an organized, logical way. It’s important to know when to use a database and be aware of its advantages.

How to Create a Database?

➖To create a Database we need tools/software to build a Database. We’ll use MySQL to create a Database, Anyone can use MySQL as it is Opensource software. Click on the link to download the free Community version of MySQL: https://dev.mysql.com/downloads/installer/

➖As soon as you Get into the MySQL command prompt. You can see the details as shown:

➖Command to Be Followed to Build the Database: let's take an example of the CSK team

Syntax: CREATE DATABASE “CSKTeam”(Note: name of the database is Case Sensitive)

➖Command to be Followed to create tables in the Database: let's consider Team2019, Team2020, Team2021;

Check where the Tables are formed using: SHOW TABLES;

➖Command to be Fill the Details of a table in the Database: let's consider Team2019

Using few data we fill the Details of the Team2019 table as shown below

Use ‘select * from team2019’ to View the Table

➖Command to be Check player with Average score less than 45 in Team2019, Use: ‘select * from team2019 where AvgScore<=45;’

➖Command to be Check Indian players in Team2019 & to Display only Name, Use: ‘select name from team2019 where Country= ‘India’;’

➖Command to Delete the Players with Average Score less than 40.

Use: ‘delete from team2019 where AvgScore<=40;’

➖Command to Change/Update the AvgScore of Murali Vijay.

Use: ‘update team2019 set AvgScore=43 where Name= ‘Murali Vijay’;’

➖Command to Add new column in the table team 2019

Use: ‘alter table team2019 add column Matches int(3);’

Since the Matches attributes are not filled they are showing ‘Null’

Congratulations you’ve made it to the end! If you read all of these stories, you will have a strong grasp of the Basics of SQL. Hope you enjoyed it! If you found this useful, please make sure to share it with friends so they can know the Basics of SQL.

--

--

Vasu Devan S

Data Scientist aspirant | Machine learning | SQL | Web scraping|Data mining|Statistics |Python |Pandas|Advanced Excel