Tuesday, August 3, 2010

Small Steps in SQL

Hello Friends,

We will learn here basics and structures in SQL Server. Before going to understand SQL Server, we have to know what is Database.

Database is storing organized collection of data based on a relationship. You may ask how you found a relation ship in the data, Consider below example. i had below data with me

Employee number: 45
DOJ : 12/12/1998
Sal: 12300
Deptno :4

Student Number: 34
DOJ: 13/12/2002
Course: ASM
FeePaid: 1200
Total Fee: 1500
Department: 6

Employee number: 5 4
DOJ : 12/1/2005
Sal: 22000
Deptno :1

Student Number: 12
DOJ: 13/12/07
Course: c++
FeePaid: 1200
Total Fee: 2500
Department: 2

From the Below data we came to know that there are two sets of data available to us (i.e. Employee, Student), we can organize this data into two Relations (i.e. Employee,Student) . We can identify the uniqueness data in each relation using relation key (i.e EmployeeNo,StudentNo).

Each relation we will called as a Table.

So, now we understand that the data in a single table will bound with a relation. This is called Relational Database management System (RDBMS). We use SQL (Structured Query Language) to manage the database.

In order to store the data, First we have to create the Relations/Tables. To manage the definitions of these relations we need to do below operations

1) Create Table
2) Alter/Change Table
3) Drop Table

Syntax for Create table in SQL: http://msdn.microsoft.com/en-us/library/aa258255%28SQL.80%29.aspx

Syntax for AlterTable in SQL: http://msdn.microsoft.com/en-us/library/aa275462%28v=SQL.80%29.aspx

Syntax for Drop Table in SQL : http://msdn.microsoft.com/en-us/library/aa258841%28v=SQL.80%29.aspx


Once you create table as per your data structures based on your sample data, You need to enter the data into data base and manage the data in database.

For data management, We need to do below operations

1) Insert data into database
2) Get/Select the data from DB
3) Update the data in DB
4) Delete the data from DB

These operations are common to manage the data in database.

Basic Syntax for Insert : http://msdn.microsoft.com/en-us/library/aa933206%28SQL.80%29.aspx

Basic Syntax for Select the data : http://msdn.microsoft.com/en-us/library/aa259187%28v=SQL.80%29.aspx

Basic Syntax for Update the data : http://msdn.microsoft.com/en-us/library/aa260662%28v=SQL.80%29.aspx

Basic Syntax for Delete the data: http://msdn.microsoft.com/en-us/library/aa258847%28v=SQL.80%29.aspx

We will learning some middle level data management quires in SQL in next sessions. Try to create some sample tables and insert the sample data into them.

Regards
Praveen

2 comments:

vinayakaprasadchepuri said...

nice help on SQL dude

pradeep said...

I learnt SQL with this "small steps in SQL"