SQL

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 25

SQL

By
P. Ramanjaneya Prasad
Associate Professor
Department of Computer Sccience
Avanthi Degree & PG College
SQL

Data ?

Data is collection of raw facts


SQL

Data
→ Processed
→ Information
→ Knowledge
SQL

Storage of Data
→ Database
SQL
What is a Database?
A database is a collection of data that is organized, which is also called
structured data. It can be accessed or stored in a computer system.

Database refers to related data in a structured form.

Database can be managed through a Database Management System


(DBMS), a software used to manage data.
SQL
Types of Database?
Relational Database: A relational database is made up of a set of
tables with data that fits into a predefined category.

Distributed Database: A distributed database is a database in which


portions of the database are stored in multiple physical locations.

Cloud Database: A cloud database is a database that typically runs on


a cloud computing platform.
SQL
What is DBMS?
An interface for operations like creation, deletion, modification, etc is
provided by DBMS.
DBMS allows the user to create their databases as per their requirement.
DBMS accepts the request from the application and provides specific data
through the operating system.
DBMS contains a group of programs that acts according to the user’s
instruction.
It provides security to the database.
SQL

User

Database

SQL
SQL

Structured Query Language


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 groups based on their nature:


SQL
SQL
What is a Table?
The table is a collection of related data entries and it consists of
columns and rows.
A table is the most common and simplest form of data storage in a
relational database.
SQL
What is a Field?
Every table is broken up into smaller entities called fields.
SQL
What is a Row or a Record?
A record, also called a row of data, is each individual entry that exists in
a table. A record is a horizontal entity in a table.
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.
SQL
SQL
SQL
Data Integrity
Entity Integrity : There are no duplicate rows in a table.

Domain Integrity : Enforces valid entries for a given column by restricting the
type, the format, or the range of values.

Referential Integrity : Rows cannot be deleted which are used by other records.

User-Defined Integrity : Enforces some specific business rules that do not fall
into entity, domain, or referential integrity.
SQL
Data Types
Numeric : Numeric Values : -1038-1 to +1038+1
Integer: -2,147,483,648 to 2,147,483,647
Float: -1.79E + 308 to 1.79E + 308
Date : Stores a date like June 30, 1991
Time : Stores a time of day like 12:30 P.M.
Char : Maximum length of 8,000 characters.( Fixed length)
Varchar : Maximum of 8,000 characters.(Variable-length).
SQL
Arithmetic Operators
SQL
Comparision Operators
SQL
Comparision Operators
SQL
Logical Operators
SQL
SQL CREATE TABLE Statement
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY( one or more columns ) );
SQL
SQL INSERT INTO Statement
INSERT INTO table_name( column1, column2....columnN) VALUES
( value1, value2....valueN);

Note: You may not use column names if you are entering all the values
of all fields, but should be in order.
SQL
SQL SELECT Statement Wild Cards
SELECT column1, column2 % - Matches one or more
FROM table1, table2 characters
WHERE [ conditions ]
GROUP BY column1, column2 _ - Matches one character
HAVING [ conditions ]
ORDER BY column1, column2

You might also like