Introduction to SQL : Structured Query Language
What is SQL ?
SQL is a standard that specifies how
- a relational schema is created
- data is inserted/updated in the relations
- data is queried
- transactions re started and stopped
- program access data in the relations
- and a host of other things to do.
SQL provides a small and concise set of commands which can be combined with dBase commands to define and access data from a database. Every relational database management system (RDBMS) is required to support/implement the SQL standard.
Various SQL Standards are :
- SQL 1 also SQL 86
- SQL 2 also SQL 92
- SQL 3 also SQL 99
There are two types of SQL :
- Interactive SQL – In interactive SQL, we enter a command, it is executed and we may get the output.
- Embedded SQL – In Embedded SQL, the SQL commands is embedded into the programs that are written in other language such as FORTRAN, Pascal, COBOL, C. The output of the SQL commands in embedded SQL is passed off to variables enabled by the program in which it is embedded.
The roots of SQL :
Difference Between SQL and other Programming Languages :
|SQL||Conventional Programming Languages|
|SQL is a non Procedural Language||These Languages are commonly Procedural.|
|SQL statements specify what data operations should be performmed rather than how to perform,||As these follows a procedure, so they need how to perform on data|
Components or Elements of SQL
There are three components of SQL –
- DDL (Data Definition Language) – is used for creation and deletion of the database. It provides a set of statements to create/define a database, modify its structure after it has been created, and destroy it after it is no longer needed.
- DML (Data Manipulation Language) – is used for manipulating the database. Manipulation means insert, modify, delete or query the data in the database. It enables users to access or manipulate the data as organised by appropriate data model.
- DCL (Data Control Language) – is used to grant and revoke authorization for database access, auditing the database use and dealing with transactions. It specifies how to restrict a user/se of users to access only certain parts of data, perform only certain types of queries.
- TCL (Transaction Control Language) – is used to manage the changes made by DML statements. It specifies how transactions can be started/stopped, how a set of concurrently executing transactions can be managed.
Data Types in SQL
Advantages and Disadvantages of SQL
- High Speed –
SQL Queries can be used to retrieve large amounts of records from a database quickly and efficiently.
- Well Defined Standards Exist –
SQL Databases use long-established standard, which is being adopted by ANSI and ISO. Non SQL databases do not adhere to any clear standard.
- SQL as a language is independent of the way it is independent of the way it is implemented internally. A quey returns the same result regardless of whether optimizing has been done with indexes or not.
- No Coding Required –
Using standard SQL, it is easy to manage database systems without having to write substantial amount of code. Also applications written in SQL can be easily ported across systems. Such porting could be required when the underlying DBMS needs to be upgraded because of change in transaction volumes or when a system developed in one environment is to be used on another DBMS.
- Emergence of ORDBMS –
Previously SQL databases were synchronous with relational database. With the emergence of object oriented DBMS, object storage capabilities are extended to relational database.
- Difficulty in Interfacing
Interfacing an SQL database is more complex than adding a few lines of code.
- Scalability –
Users have to scale relational database on powerful servers that are expensive and difficult to handle. To scale relational database, it has to be distributed onto multiple servers. Handling tables on different servers is a chaos.
|Question on Normal Forms||SQL Commands and Some Rules for Writing SQL Commands|