This Whole world is running because of data and its increasing at an exponential rate. You have data around you everywhere and all the time. Even your personal stuff is your data to use your stuff in better way it needs to be organized well so that they can be found out easily. And this is where a DMBS ( Data Base Management System) Comes in. They do the job of organizing your data.

Now I hope everyone understand that computers understand the language of 0 and 1 which is called a binary language. They don't understand our simple English or Hindi. Even what i am writing here is being interpreted through 0 and 1 only, which some software is doing it for the computer. In the same way database understand through their own language and that language is called as SQL ( Structured Query Language).

What Kind of Data?

A Database can store anything. You just have to define in a proper way that what exactly is needed to be stored so that the DBMS can organize it for you, to be retrieved later. We define types of data to be stored and that data type will accept only that type of data. For example , a phone number will always be an object of type number. You cannot have a phone number as : 984550ADDD.. correct ? So we need to defined the proper type for the data to be stored for better management.

How data is Stored?

For a layman's understanding, a database stores data in the form of a table , which is a combination of rows and Columns. It will organize data in such a way that an information related to each other with different objects is stored in one row and different in other. And different objects are stored in columns. Lets see the example to clearly understand this. ( Note: i'll explain about the tool being used and how to use it, in different tutorials). Lets focus on understanding the concept first.


Lets start with you only. You are a person and you have the following data related to you like : First Name, Start Name, Age , Phone No. There are many other things related to you but lets start with these only. So, the data for for different people will be stored like this as shown in the table.Basic DataAnd this is very basic for of data. The table like that contains millions of rows and hundreds of column because they need to store huge amount of data.

Working with SQL

As stated earlier, SQL is a languages which a database management system understands and to make them understand that, we write the SQL statements with which they understand our requirements and return us the relvant answers. So lets start with it rightaway. First we will learn the command to create the table. As defined earlier, we have personal data to store and so lets name the table as Personal. So to create a table with name personal we need to write the below command in sql Developer. You need to either install oracle db and run the below commands in sql developer or you can use the open source wamp server which has mysql database to use. I would prefer wamp. Its free, small , open source and easy to install.

CREATE TABLE `personal` (
  `First Name` varchar(50) NOT NULL,
  `Last Name` varchar(50) NOT NULL,
  `Age`      int(10) NOT NULL,
  `Phone no` int(10) NOT NULL
)

The above query will create the table personal with different types of data.

Understanding Data Type

As you saw, we create the table with two different types of data which are varchar and INT.  Varchar means variable character which means it can store string of different length. In our case we have defined the length of that string to be 50  which means the first name and the last name field cannot be more than 50. Also we have written not null in front of them which means that there should be some value for the Names and the numbers and they cannot be left as empty. Its totally on our requirement where we want to have some field as null or not. For eg. you don't want to mention last name and phone number, so you can create the table by removing not null from those fields. But currently we are having all fields as mandatory.

Lets Insert the data

Now since our table is ready, but it doesn't have any data yet, which is useless, so its time to insert the data in that. And to insert the data we have another simple query as shown in screenshot below.

Insert Data

And after running the above command, you can see the data as shown in the first screenshot earlier.

Congratulations, you have just created your first table using SQL and inserted data in that. Now try creating different types of tables and insert some data accordingly. This is just the beginning and there is lot to come. But before that i would like to know your inputs to start working on rest of the tutorials. Because it really won't make sense if it is not helping you in any way. Also you can pm me in case you are facing issues in creating or inserting data.

There are lot more intersting things to come while learning SQL. And also it is needed badly in Software Industry. So Happy Learning.


Like it on Facebook, +1 on Google, Tweet it or share this article on other bookmarking websites.

Comments (0)

There are no comments posted here yet