Sunday, August 14, 2011

Introduction to SQL.....

            Before learning the concepts of SQL and PL/SQL we need to know the importance of the ORACLE language and also about few introductory things. So, In this post I am going to give Introduction to SQL which will give  the better understanding of why to learn this language. Also I will provide some basic information about different topics related to SQL which I am going to discuss about in my upcoming posts.
           As I mentioned in my previous post we need to have a database in our system to practice the SQL or PL/SQL. So, for us database is the most important thing. So, we need to know about what is a Database and why we need it.

What is a Database :: ?
            The answer to this question is very simple. Database is the place where we can store our data. The Oracle database is designed in such a way that any data we want to store in it, we can store it in the form of 2 dimensional tables (In database terminology we will call them as Relations).
            A table will contain Rows (In database terminology we will call them as Tuples) and Columns (In database terminology we will call them as Attributes). I will explain this concept with small example.
            Basically tables will contain structure and data. The structure of the table includes Name of the table, Columns of the table(along with their names and data types along with constraints if any). The name of the table should be unique (duplicate names are not allowed). The name should be in such a way that by seeing the name itself we must be able to identify the type of information  stored in the tables.
 For EX: See the following table.

               EMP:    Empno
Empno
Ename
Deptno
Hire_date
Sal
1
Ram
10
10-jul-2011
25000
2
Raj
20
15-jul-2011
15000
3
Rao
30
20-jul-2011
10000
 
  Name of this table is EMP, means employee. So, by seeing this name itself we will know that Employee details were stored in this table.
     This table contain 5 columns. Generally each column of a table will specify one unique attribute of the data which we are going to store in the table. If you observe this table we have columns named as Empno (which will give us employee number of the employee), Ename (name of employee), Deptno (dept to which employee belongs), Hire_date( joining date of employee) and Sal(sal of employee). Like this each column is specifying the unique feature of a particular employee. Regarding data type we will discuss about it in coming posts. But to give some idea, The data type will specify the type of data which we are going to store in that particular column (Ex : Numeric, character.... etc).
      Now coming to the data part of the table, Rows will contain the data in the tables. Each row will contain some unique information of the type of the data which we are going to store. In our example each row will contain unique information of  an employee of the company. Generally we will maintain only one row for an employee in the table. (This can be maintained with the constraints about which we will discuss in coming posts)
      We can store any type of data in the database in form of tables . We can store pictures and files also.
So, By this we have got some idea about what is a database. Now next question is why we need database?

Why we need a Database :: ?

    Let me explain this with small example. Let us take the example of GMAIL, through which we can send mails, we can chat with friends.... by logging in with our credentials(Username and Password).
    Here in Gmail our Usernames should be unique. While registering it will ask to enter unique user name by checking the availability and each username will be associated with a password. So, where this information will be stored?? This information will be stored in the tables of a database server which is located at the company. So, each time when you are trying to login then it will validate the information with the data stored in the database and it will do appropriate action.
   Similarly in real life almost in all the places database becomes a mandatory thing as we can store data into it from any place and we can access that data from any place. Take Banking, Railways ticket reservations, Bus ticket reservations, Cinema ticket reservations and information, Hospitals..... any place you take... they need a database to maintain the information.

So, Now we understand the importance of the database in our real life. Now, here comes most importane question. What is SQL?

What is SQL :: ?
   
      SQL means Structured Query Language. The statements which we are going to write in this language will be called as Queries. Each query will be having its own structure. That is why this language is called as Structured Query Language. Ok fine. Now we know what is SQL. The next question is Why we need SQL?

Why we need SQL :: ?

     So as discussed in the above sections,we will store the information in the database in the form of tables. How will you store?? we cannot take it by hand and we cannot put it in the database right.. Similarly How will you see the information?? How will you modify the information?? To do all these things we need a mode of communication with the database. We need to interact with the database by some medium. Here comes the usage of a Database language by which we can perform all the above mentioned tasks on the database. One such type of Language is SQL.
     So, SQL is a communication language which will be used to interact with the database.
So, As part of SQL we are going to learn about how to perform all the above mentioned tasks. 

So, this is a small introduction to what we are going to discuss in my upcoming posts. If you have any queries you can post them through comments.


17 comments:

  1. Can please give me the more clarification on what is plsql, and diff b/w sql and plsql?

    ReplyDelete
  2. Hi,

    I will discuss about PL/SQL in coming posts.
    But here I will give yo brief idea. PL/SQL
    means Procedural extension to SQL. In case
    of sql what we will do is, we will write
    SQL queries to perform required operations.
    If the task you want to perform requires
    multiple SQL queries to be executed, then
    instead of running them individually we can
    keep them inside a Procedure and we can
    run that procedure.

    So, PL/SQL is extension for SQL where we
    will use different PL/SQL functionality
    along with SQL statements to perform the
    required tasks.

    ReplyDelete
  3. Can you please brief me how many types of SQL'S we have?
    i mean SQL,PL/SQL and so on and where they exactly used in real time?

    ReplyDelete
  4. Hi,

    SQL is a language. The type of SQL is depending on the type of database we are using. For example if we are using Oracle Database then we have to use SQL and PL/SQL languages. Similarly if we are using Microsoft SQL Server database then we have to use Transact SQL language.

    Thanks,
    Rambabu

    ReplyDelete