SQL(Structured Query Language) Tutorial 
Database Terms - and their Meanings 
SQL(Structured Query Language) Tutorial
Tutorial Contents Page

SQL(Structured Query Language) Tutorial - Contents


SQL(Structured Query Language) Tutorial
SQL, or Structured Query Language, is the language used to access and manipulate data within a database. It is very simple and very powerful.
Contents of the tutorial
Database Terms - and their Meanings
Before learning the language you will have to learn some words and their meanings. Basic stuff, but you cannot continue without them.

SQL Statements

Fetching the Data

SELECT Statement
First thing to learn in SQL is the SELECT command. This command is used to get the data from the database. And its used all the time.
WHERE is the new if
All languages I know use 'if' for conditions - except SQL. It uses where for conditional statements.
Sorting the Results using ORDER BY
Often getting the data is not enough - you have to sort the data also. This is made easy by the ORDER BY clause.
Group Multiple Rows using GROUP BY
Sometimes you have to group together multiple rows in the result and then get an aggregate from the grouped rows - that's the function of GROUP BY.
SQL Functions
We had a small preview of SQL functions in the last page about grouping. We saw AVG() in action. Here we are going to see the other available functions. Some of the functions may be same across different SQL databases - but many others will be different.

Manipulating the Data

Inserting Data
So far we where looking at how to get data from the database. But to get that data, there must be some data in the tables. Until now, I provided pre-existing data for you to play around with. Now lets see how to insert your own data into the table. Introducing the 'INSERT' command...
Update/Delete Existing Data in a Table
Now that we know how to insert new data, let see how to edit the existing data. You can edit the data in a table using the UPDATE command.

RDBMS - Relation between Tables

Joining Data From Multiple Tables
Often, the data you need will be spread across two(or more tables). In such cases, we have to join these tables together to get the data. The JOIN statement in SQL is created for a situation like that.
Database Relations
There will be many cases when the data in one table is related to the data in another table. This connection between two tables is called a relation. When there is such a relation between two tables, these tables will be connected by inserting the primary key of one table into the corresponding row of the other table. The field used in such a way to connect the two tables is known as the foreign key.
LIMIT Command
There are situations where you don't need all the results in the database - you just need a few. Say you need the names of the first 5 characters in the database. If you run a SELECT query, you will get the entire table. But if you use the LIMIT option you can limit the number of results. To get the just 5 characters, the command would be...
Database Designing
Database Designing is arguably the most important part of a project. Unfortunately, it cannot be taught. The only way to learn how to design is by design databases by yourself. You will make mistakes - but after a dozen or so databases, you would get the hang of it. I'll try to pass on the lesson I learned from designing databases and some huge database books.

The End

Other Stuff In SQL
There are a lot of areas I have not covered. By this tutorial, I wanted to give you start in SQL - not a reference manual. So I only included the elements that are most likely to be used. So here is a list of stuff that I have not touched - and the reason its left untouched...
Some reference material for learning SQL, Database, RDBMS, etc. Books, Manuals, Web sites and more.
This page provides the answers to some questions asked to the readers through the series. If you cannot find the answers yourself, refer the Appendix page.
SQL(Structured Query Language) Tutorial 
Database Terms - and their Meanings 
Subscribe to Feed