You are here: Home / Topics / Introduction to Structure Query Language (SQL)

Introduction to Structure Query Language (SQL)

Filed under: MySQL on 2023-03-02 06:15:51

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

 

Query

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.

Tuples

Rows of a relation are referred as tuples.

Attributes

Columns/fields of a relation are referred as attributes.

Degree

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.

Cardinality

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

View

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

Key

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.

About Author:
V
Vishal Gupta     View Profile
Hi, I am Vishal Gupta. I like this Website for learning MCQs. This website is good for preparation.