Sunday, July 20, 2008

SQL Basics


What's SQL ?

In 1971, IBM researchers created a simple non-procedural language called Structured English Query Language. or SEQUEL. This was based on Dr. Edgar F. (Ted) Codd's design of a relational model for data storage where he described a universal programming language for accessing databases.
In the late 80's ANSI and ISO (these are two organizations dealing with standards for a wide variety of things) came out with a standardized version called Structured Query Language or SQL. SQL is pronounced as 'Sequel'. There have been several versions of SQL and the latest one is SQL-99. Though SQL-92 is the current universally adopted standard.
SQL is the language used to query all databases. It's simple to learn and appears to do very little but is the heart of a successful database application. Understanding SQL and using it efficiently is highly imperative in designing an efficient database application. The better your understanding of SQL the more versatile you'll be in getting information out of databases.

There are four basic commands which are the workhorses for SQL and figure in almost all queries to a database.
INSERT - Insert Data
DELETE - Delete Data
SELECT - Pull Data
UPDATE - Change existing Data
As you can see SQL is like English.
Let's build a real world example database using MySQL and perform some SQL operations on it.
A database that practically anyone could use would be a Contacts database.
In our example we are going to create create a database with the following fields:
• FirstName
• LastName
• BirthDate
• StreetAddress
• City
• State
• Zip
• Country
• TelephoneHome
• TelephoneWork
• Email
• CompanyName
• Designation
First, lets decide how we are going to store this data in the database. For illustration purposes, we are going to keep this data in multiple tables.

This will let us exercise all of the SQL commands pertaining to retrieving data from multiple tables. Also we can separate different kinds of entities into different tables. So let's say you have thousands of friends and need to send a mass email to all of them, a SELECT statement (covered later) will look at only one table.
Well, we can keep the FirstName, LastName and BirthDate in one table.
Address related data in another.
Company Details in another.
Emails can be separated into another.
Telephones can be separated into another.



Link

2 comments:

Husband dady... said...

THANK YOU,
i was lookin for sql basics and you provided it in a cool way startin frm whn it really originated.
Nice notes

Walia's said...

Welcome....u can leave comment when ever you have any query or if you want any notes on any topic related to IT.

GIS

GIS

From: poonam.rwalia, 9 minutes ago





SlideShare Link

Benefits of Using computer software