Home » SQL

Introduction to Structure Query Language (SQL)

Learn: What is SQL (Structure Query Language)? what are the basic terminologies of SQL?
Submitted by Shubham Singh Rajawat, on August 08, 2017

SQL (Structure Query language) is a standard database language for creating, maintaining, manipulating, and destroying relational database.


A query is a request/question expressed in a formal way with intent to get some result .A 'SELECT is a query used for retrieval of data.

Relational Database

Relational database depends on relational data model in which data is arranged in columns and rows as relation (tables), having unique key in each row.

For Example: The table below shows a relation (table) of name Student which stores Enroll_No, Student_Name, DOB, Gender and Age.

SQL table example


Rows of a relation are referred as tuples.


Columns/fields of a relation are referred as attributes.


The number of attributes in a relation determines the degree of a relation. A relation with having ‘n’ attributes is said to be a relation of degree n. E.g. Degree of Student is 5.


he number of tuples in a relation determines the cardinality of a relation. E.g. Cardinality of Student is 3.


A view is a virtual table that does not exist on its own but it is derived from one or more tables.


Any one attribute or a combination of attributes that uniquely identifies a record in the table is called key. E.g. in Student table Enroll_No is a key since it is unique for each student.

Types of keys in SQL

  1. Primary Key
    A primary key is a set of one or more attributes that can uniquely identify tuples within a relation.
  2. Candidate Key
    All attribute combination in a table that can serve as a primary key are candidate keys, as they are candidate for primary keys.
  3. Alternate Key
    A candidate key that is not a primary key is called alternate key.
  4. Foreign key
    A non-key attribute whose values are derived from the primary key of other table is called foreign key.
  5. Composite key
    A key that consist of more than one attribute to uniquely identify a tuple is called composite key.
  6. Super key
    Super is a set of one or more columns to uniquely identifies rows in a table.

Queries in SQL can be categories as:

1) Data Definition Language (DDL)

DDL provides command for defining relation schemas, deleting schemas and modifying relation schema i.e. it works on the structure of a relation schema for e.g. CREATE TABLE, ADD COLUMN, DROP etc.

2) Data Manipulation Language (DML)

DML provides command manipulate data in a table for e.g. INSERT, UPDATE, DELETE etc.

3) Data Query Language (DQL)

It is used to extract the data from table for e.g. SELECT.

4) Transaction Control Language (TCL)

It is used to manage transactions in database means they are used to manage changes made by DML statements for e.g. COMMIT, ROLLBACK etc.



Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.