SQL-Tutorial-Introductio.sk

You might also like

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

© wideskills.

com
© wideskills.com
sk
SOME OF THE DATABASE MODELS
Hierarchical
Network DBMS Relational DBMS
DBMS
2
Shaik

2
1
Shaik

1
© wideskills.com
© wideskills.com

Why Relational Model is Popular than other Model.


sk
sk
sk
sk
sk
sk
sk
© wideskills.com
© wideskills.com

New versions of the standard were published in 2011[14] and, most recently, 2016.
WHAT IS SQL…
.

SQL is the standard used to manage data in relational tables. Structured Query Language
normally referred as SQL and pronounced as SEE QU EL..

SQL allows users to create databases, add data, modify and maintain data. It is governed by
standards maintained by ISO(International Standards Organization).

Example of a relational table:


Employee Department

Emp Id Emp Name Age Dept_id Dept_id Dept_name

1 John 40 1 1 Accounts

2 Linda 35 1
2 Production
3 Max 30 2
sk

SQL SYNTAX AND QUERY

SQL is case in-sensitive, that is keyword SELECT and select is same for SQL. Every SQL
command should end with a semi-colon (;).

If the syntax is not proper, then executing the command would result in syntax error.

Command used to fetch data from table is called as query. A basic SQL query consists of
SELECT, FROM and WHERE clause.
SQL SELECT Command example:
SELECT col1, col2, col3,…..
FROM table_name
WHERE condition;
DATATYPES IN SQL
Data type is the attribute of the data expected in the column. Depending upon the SQL
implementation (version) different data types are available. Whenever you create a
column using the data type, the SQL Implementation program would allocate appropriate
amount of space to store the data.

Data types are broadly categorized into Numerics, Strings, Binary, Datetime, Collection
and XML. Most commonly used data types are Integer, Decimal, Float, Character,
Varchar, Boolean, Date.

Example:
1. Boolean Value : Return value = “True”
2. INT : 5400, -2500
3. Numeric or Decimal: Decimal(4,2) = 1000.24
.

OPERATORS AND EXPRESSIONS


IN SQL

In SQL, operators are used in an SQL statement’s WHERE clause to perform different operations
like comparison, logical and arithmetic operations. Operators that can be used are logical,
comparison and Arithmetic. The Operators include <,>,<>,AND,OR,BETWEEN,ISNULL,+,-,?,
% etc.

Generally in any programming language, expression is a combination of values, constants,


variables, operators and functions that results in a value. In SQL, expressions are used to query
database/table to get specific data.

Syntax:
SELECT cols|expressions FROM table_name
WHERE condition(using operators|expressions);
.

SQL commands can be used to create databases, edit data in tables, delete data and
maintain data in tables.
SQL commands are classified into 3 groups: DDL(Data definition Language),
DML(Data Manipulation Language) and DCL(Data Control Language).

DD DM
DCL
LCREATE
LSELECT
GRANT
ALTER
INSERT INTO
DROP

CREATE UPDATE
INDEX REVOKE
DROP INDEX DELETE

.
© wideskills.com

Frist developers will create a front-end web pages using the programming language
Once that is done, we or the SQL developers will create the necessary databases for the project
depending upon the requirement - this process is knows as backend

Now once the database is created in the RDBMS system there should be a communication to the
front end and the backend so that that the data gets stored in the backend #for that they create a
Connection String in the web config file page at the front end
© wideskills.com

CREATE DATABASE AND TABLE

As part of the Data Definition Language (DDL) under SQL, CREATE keyword is used to create databases and
tables.

One would need to first create Database and then under that database create the required tables.

Syntax for creation of database:


CREATE DATABASE database_name;

The SQL CREATE TABLE statement allows you to create and define tables in a database.
Syntax for creation of table:
CREATE TABLE tablename
( column1 datatype NULL/NOT NULL,
Column2 datatype NULL/NOT NULL
…………………
…………………
PRIMARY KEY (column name or names),
FOREIGN KEY(column name) REFERENCES Tablename(column name)
); Optional
© wideskills.com
© wideskills.com

You might also like