Introduction to Structured Query Language (SQL)
#1 Article on the SQL Tutorial Series
Introduction
Manipulating data to get information out of it is a vital skill to know as a developer. Even if you are not a developer, it is a great skill to learn. SQL is a query language that is very useful in sending queries to the database.
As this is the first step in moving forward in the series, it is only fair we understand what data and databases mean. Then we will proceed to understand relational database which is a type of database and SQL, which is a programming language used to query databases, and why you should have a grasp of it. Sit back and let's ride through it.
What is a Database
Data is a very important aspect of our lives. We deal with it every day. Data could be anything related to an object. Thus there is a need to collect it and keep it organized.
A Database is an organized system of data collection. When data is stored in a database, it makes management easier, and such data could be accessed electronically.
A small collection of data could be stored in local storage, on a file system. A large collection of data could be stored in cloud storage. There are different types of databases. Read more on databases
Relational Database
This is a type of database whereby data can be stored and represented in tables. It provides access to data information which are related to one another.
Each row in the table represents a record with a unique ID that is only peculiar to a record. The column holds attributes and each value in the record(row) has an attribute.
Here is an illustration of a relational database. For instance, you run a small business where a customer can make an order for the product you are selling.
You might want to have a customer-info table that holds data about the customer like the name, address, e.t.c of the customer. Each record as I mentioned earlier holds a unique ID.
You might also want to have a customer-order table that holds data like the ID of the customer that placed the order, the date the order was placed, the price, e.t.c. but not the information about the customer
These two tables include an attribute: Customer_id. With this, a relationship can be established between the two tables.
When an order is submitted to the customer-order table, the database can be queried and information about that order can be retrieved.
The customer_id that is peculiar to that order can then be used to establish a relationship with the customer_info table and get all information about the customer that made the order.
For instance, on the customer-order table, ID number 3 shows that a customer made two orders. With that number, a relationship can be made with the customer-info table so that personal information about the customer can be retrieved.
Thus, the ID column has provided a relationship between these two tables.
SQL Overview
SQL is a query language used to manipulate and transform data in a relational database.
It is best for structured data that can be neatly organized in a table of rows and columns. The data stored in a SQL database needs a predefined schema.
A SQL database is very common with the e-commerce website as it offers integrity of data by defining exactly what a transaction is and how it interacts with your database.
It avoids database tables from becoming out-of-sync, which is super important for financial transactions
Why you should learn and use SQL
There are numerous reasons why you should have the knowledge of SQL in your skillset. Here are some reasons:
- It is simple. The syntax uses plain English words which makes understanding easier and faster.
- SQL allows you to query the database in a variety of ways. Information can be extracted this way and questions about the data can be answered.
- It is used on websites for back-end data storage and data processing solutions. For instance, user registration data can be stored so that when the user can have access to it at any time.
- SQL provides CRUD functionality for databases. CRUD stands for Create, Read, Update and Delete.
- Allows users to create views, and store procedure functions in a database
Conclusion
We are surrounded by data and knowing how to get information out of it can be useful to you as an individual or to your team. Learning SQL is a great deal because millions of data out there are structured and they might have relationships with one another in their databases.
Subsequent articles in this series will dive deeper into SQL and how to work with it. Give your 2 cents on this article.
Let's Connect
Thanks for reading to the end...