0% found this document useful (0 votes)
7 views

Introduction to SQL

Sql language

Uploaded by

vaibhavjha421
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Introduction to SQL

Sql language

Uploaded by

vaibhavjha421
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Database

Fundamentals
Prof. Anil Kumar
Basic Terminologies
Terminologies
What is a table?
• The data in an RDBMS is stored in database objects which are called as tables.
• This table is basically a collection of related data entries and it consists of
numerous columns and rows.
• A table is the most common and simplest form of data storage in a relational
database.
• The following program is an example of a CUSTOMERS table −
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+----------------------------------------
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 |
| 5 | Hardik | 27 | Bhopal | 8500.00 |
| 6 | Komal | 22 | MP | 4500.00 |
| 7 | Muffy | 24 | Indore | 10000.00 |
+----+----------+-----+-----------+----------+----------------------------------------
Terminologies
What is a field?
• Every table is broken up into smaller entities called fields. The fields in the
CUSTOMERS table consist of ID, NAME, AGE, ADDRESS and SALARY.
• A field is a column in a table that is designed to maintain specific information
about every record in the table.
What is a Record or a Row?
• A record is also called as a row of data is each individual entry that exists in a
table. For example, there are 7 records in the above CUSTOMERS table.
• A record is a horizontal entity in a table. Following is a single row of data or record
in the CUSTOMERS table −
+----+----------+-----+-----------+----------+----------------------------------
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |
+----+----------+-----+-----------+----------+----------------------------------
Terminologies
What is a column?
• A column is a vertical entity in a table that contains all information associated with
a specific field in a table.
• For example, a column in the CUSTOMERS table is ADDRESS, which represents
location description and would be as shown below −
+-----------+-------------
| ADDRESS |
+-----------+-------------
| Ahmedabad |
| Delhi |
| Kota |
| Mumbai |
| Bhopal |
| MP |
| Indore |
+----+------+-------------
Introduction to SQL
What is SQL
• SQL stands for Structured Query Language
• SQL is Structured Query Language, which is a computer language
for storing, manipulating and retrieving data stored in a relational
database.
• SQL is the standard language for Relational Database System.
All the Relational Database Management Systems (RDMS) like
MySQL, MS Access, Oracle, Sybase, Informix, Postgres and SQL
Server use SQL as their standard database language.
• Also, they are using different dialects, such as −
– MS SQL Server using T-SQL,
– Oracle using PL/SQL,
– MS Access version of SQL is called JET SQL (native format) etc.
Why SQL

SQL is widely popular because it offers the following advantages −


• Allows users to access data in the relational database
management systems.
• Allows users to describe the data.
• Allows users to define the data in a database and manipulate that
data.
• Allows to embed within other languages using SQL modules,
libraries & pre-compilers.
• Allows users to create and drop databases and tables.
• Allows users to create view, stored procedure, functions in a
database.
About SQL

A Brief History of SQL


• 1970 − Dr. Edgar F. "Ted" Codd of IBM is known as the
father of relational databases. He described a relational
model for databases.
• 1974 − Structured Query Language appeared.
• 1978 − IBM worked to develop Codd's ideas and
released a product named System/R.
• 1986 − IBM developed the first prototype of relational
database and standardized by ANSI. The first relational
database was released by Relational Software which
About SQL

SQL Commands
• The standard SQL commands to interact with
relational databases are CREATE, SELECT,
INSERT, UPDATE, DELETE and DROP. These
commands can be classified into the following
groups based on their nature −
– DDL - Data Definition Language
– DML – Data Manipulation Language
– DCL – Data Control Language
About SQL

DDL - Data Definition Language


Command & Description

CREATE
Creates a new table, a view of a table, or other object in the database.
ALTER
Modifies an existing database object, such as a table.
DROP
Deletes an entire table, a view of a table or other objects in the
database.
About SQL

DML - Data Manipulation Language

Command & Description


SELECT
Retrieves certain records from one or more tables.
INSERT
Creates a record.
UPDATE
Modifies records.
DELETE
Deletes records.
About SQL

DCL - Data Control Language

Command & Description


GRANT
Gives a privilege to user.
REVOKE
Takes back privileges granted from user.
SQL Constraints
• Constraints are the rules enforced on data columns on a table.
These are used to limit the type of data that can go into a table.
This ensures the accuracy and reliability of the data in the
database.
• Constraints can either be column level or table level.
– Column level constraints are applied only to one column whereas,
– table level constraints are applied to the entire table.
SQL Constraints(cont.)
• Following are some of the most commonly used
constraints available in SQL −
– NOT NULL Constraint − Ensures that a column cannot have a NULL
value.
– DEFAULT Constraint − Provides a default value for a column when none
is specified.
– UNIQUE Constraint − Ensures that all the values in a column are
different.
– PRIMARY Key − Uniquely identifies each row/record in a database table.
– FOREIGN Key − Uniquely identifies a row/record in any another
database table.
– CHECK Constraint − The CHECK constraint ensures that all values in a
column satisfy certain conditions.
– INDEX − Used to create and retrieve data from the database very
© 2016 Microsoft Corporation. All rights reserved. The text in this document is available under the Creative Commons Attribution 3.0 License, additional terms may apply. All other
content contained in this document (including, without limitation, trademarks, logos, images, etc.) are not included within the Creative Commons license grant. This document does
not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes.
This document is provided "as-is." Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear
the risk of using it. Some examples are for illustration only and are fictitious. No real association is intended or inferred. Microsoft makes no warranties, express or implied, with
respect to the information provided here.

You might also like