Introduction
SQL i.e. Structured Query Language is a querying language for relational database. SQL has many flavors some of which are MSSQL, MYSQL, SQLite, PostgreSQL etc. All of these are for manipulation and management of relational databases. SQL provides set of commands that help interact with the database such as creating, modifying and querying data. Like any other languages SQL has levels of learning,
i.e. beginning, intermediate and advance. We will talk about thin brief later on.
i.e. beginning, intermediate and advance. We will talk about thin brief later on.
With SQL we can manage our data in more organized form like in table easy for us to query them when ever we need such as deleting, inserting, update.
Well SQL does have many types and variation of its own and each have their own purpose. They are
- Data Declarative Language (DDL) --- Create, Alter, Drop
- Data Manipulation Language (DML) --- Select, Insert, Update, Delete
- Data Control Language (DCL) --- Grant, Revoke
- Transaction Control Language (TCL) --- Commit, Rollback, Savepoint
- Data Query Language (DQL) --- Select
Learning Level of SQL
Basic
For beginners, SQL can be started from gaining theoretical knowledge, like what is schemas, relational database, tables, row, column, primary key, foreign key etc.
Lets start from relational database, RDB is a kind of database which is organized and stored in table form i.e in form of rows and columns.
This is a simple example of a data of fruits in tabular form, id and name are the columns and the values such as 1, Apple, 2, Banana in each line are row. To enter these data in SQL database we need to prepare database schema. A schema is like a guide that helps user to insert data into the table and also manipulate them. For above data the schema is :
create table fruits(
id int,
name varchar(30)
);
Don't worry we will go through these commands as well. The schema is like a blue print to the database which helps us to identify the data types of each entity as well like, id is an integer where as name is a string which in SQL is denoted by varchar.
Moving on to keys, primary key is a column or the set of columns that uniquely identifies each rows or records of table. This really helps in querying.
Here customerid is a primary key and the command for this is:
CREATE TABLE Customers (
CustomerID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Email VARCHAR(100)
);
Moving on to the foreign key, it is a type of key that refers to the primary key of another table. Foreign key concept is generally used while working with joins.Well as we see customerid acts as foreign key in the order table which indeed is a primary key in customer table.
While we know SQL can be used to manipulate data in database, we need the background of how SQL works. Data manipulation includes inserting, updating, deleting, filtering, applying aggregation functions etc. We have different commands or say SQL syntax for all of these data manipulation tasks, which is a separate topic for basics practical.
Conclusion
Hence, these are some theoretical backgrounds for beginners to get started, there are much more to cover that includes practically manipulating data with basics set of commands, which I will continue further in next blog.
Comments
Post a Comment