Structured Query Language (SQL) _ Edu4Sure Training.pptx

Edu4Sure
Edu4SureEdu4Sure
Structured Query Language
Introduction
 SQL is a standard language for
storing, manipulating and retrieving
data in database
 Same language can be used to query
data in MySQL, SQL Server, MS
Access, Oracle, Sybase, Informix,
Postgres, and other database
systems
Why SQL?
 Universal Language
 Open Source - Easy to Learn & Use
 Manage Million Rows of Data
 High in Demand
Data, Datasets And Database
Data
• Data are observations or
measurements
(unprocessed or
processed) represented as
text, numbers, or
multimedia
• Example: Details of
employees like Name, Age,
Town, etc. written
Dataset
• A dataset is a structured
collection of data generally
associated with a unique
body of work
• Example: Details of
employees of one town
organized alphabetically
Database
• A database is an organized
collection of data stored as
multiple datasets
• Example: Alphabetically
arranged details of all the
employees from all the
towns, stored in an
electronic unit
Why Database?
 Need of Hour for every business – small or big
 Manage vast volumes of data
 Keeps your data safe & secure
 Make meaningful decisions
 Manipulate & update data
Understanding
Database
 A database is an organized collection of
information or data
 A database is stored in an electronic storage
 Databases makes management of data easy
Relational
Database
• Stores data in form of tables
• Tables can be connected or related to each
other based on common data
• Supports SQL for querying
Use Case: Data Fetching Process
Database
API
Web Access
Any Program
Application
Programming
Interface
Data
Normalization
 Data normalization is generally
considered the development of clean
data
 Eliminating unstructured data and
redundancy (duplicates) in order to
ensure logical data storage
Data Normalization - 3 Normal Forms
1 NF
• Each entry must have only
one single value for each
cell
• Each record must be
unique
2 NF
• Data must have only one
Primary Key
• Then, relationships can be
created through new
foreign key labels
3 NF
• Data in a table must only
be dependent on the
primary key
• If the primary key is
changed, all data that is
impacted must be put into
a new table
Constraints
Related to
Data
Normalization
 Primary Key (Parent Table, Referenced Table)
 Foreign Key (Child Table)
 Composite Key
 Example on the Next Page
PersonID LastName FirstName Age
1 Hansen Ola 30
2 Svendson Tove 23
3 Pettersen Kari 20
Persons Table Orders Table
OrderID OrderNumber PersonID
1 77895 3
2 44678 3
3 22456 2
4 24562 1
 Notice that the "PersonID" column in the "Orders" table points to the "PersonID" column in the
"Persons" table
 The "PersonID" column in the "Persons" table is the PRIMARY KEY in the "Persons" table
 The "PersonID" column in the "Orders" table is a FOREIGN KEY in the "Orders" table
 The FOREIGN KEY constraint prevents invalid data from being inserted into the foreign key
column, because it has to be one of the values contained in the parent table
 A composite key is made by the combination of two or more columns in a table that can be used
to uniquely identify each row in the table when the columns are combined uniqueness of a row is
guaranteed, but when it is taken individually it does not guarantee uniqueness.
 It can also be understood as a primary key made by the combination of two or more attributes to
uniquely identify every row in a table.
ER Diagram
It displays the relationship of
entity sets stored in a database.
What is Schema
 A schema is a list of logical structures of data.
 Three Types
o Logical Schema: ER Diagram
o Physical Schema: The Physical Schemas shows the databases and the objects that
they contain. This tells how the data will be stored in the storage device.
o View Schema: It shows only those data to a view group in which they are interested
and hides the remaining details from them.
DATABASE TRANSACTION MODELS
 ACID Model (Atomic, Consistent, Isolated, Durable)
 BASE Model (Basically Available, Soft State, Eventually Consistent)
Deciding on the right database management system
ACID Database Model
• Atomic – Each transaction is either properly carried out or the process halts and the
database reverts back to the state before the transaction started. This ensures that all data
in the database is valid.
• Consistent – A processed transaction will never endanger the structural integrity of the
database.
• Isolated – Transactions cannot compromise the integrity of other transactions by
interacting with them while they are still in progress.
• Durable – The data related to the completed transaction will persist even in the cases of
network or power outages. If a transaction fails, it will not impact the manipulated data.
BASE Database Model
• Basically Available – Rather than enforcing immediate consistency, BASE-modelled
NoSQL databases will ensure availability of data by spreading and replicating it across the
nodes of the database cluster.
• Soft State – Due to the lack of immediate consistency, data values may change over time.
The BASE model breaks off with the concept of a database which enforces its own
consistency, delegating that responsibility to developers.
• Eventually Consistent – The fact that BASE does not enforce immediate consistency
does not mean that it never achieves it. However, until it does, data reads are still possible
(even though they might not reflect the reality).
Which Databases are ACID compliant?
Relational database management system
MySQL
PostgreSQL
Oracle
SQLite
Microsoft SQL Server
Which Databases are BASE compliant?
 NoSQL databases
 MongoDB
 Cassandra
 Redis
 Amazon DynamoDB
 Couchbase
Use Case Examples
 ACID: Money transfers
 BASE: Social network feeds
SQL
Commands
DDL – Data Definition Language
DML – Data Manipulation Language
DCL – Data Control Language
TCL – Transaction Control Language
DQL- Data Query Language
DDL
CREATE ALTER DROP
DATABASE
Objects
Commands TRUNCATE
TABLE VIEW
DML
DELETE
Commands INSERT
INTO UPDATE
DCL
Commands GRANT REVOKE
TCL
SAVEPOINT
Commands COMMIT ROLLBACK
SET
TRANSACTION
DQL
Commands SELECT
Naming
Connotations
 tbl_: Table
 PK_: Primary Key
 vw_: View
 ix_: Index
 clix_: Clustered Index
Structured Query Language
DATABASES PRACTICAL
Structured Query Language
TABLES PRACTICAL
Structured Query Language
DATA TYPES
Data Types (String)
Data Type Description Max Size Storage
char(n) Fixed width character string 8,000 characters Defined width
varchar(n) Variable width character string 8,000 characters 2 bytes + number of chars
varchar(max) Variable width character string 1,073,741,824 characters 2 bytes + number of chars
text Variable width character string 2GB of text data 4 bytes + number of chars
nchar Fixed width Unicode string 4,000 characters Defined width x 2
nvarchar Variable width Unicode string 4,000 characters
nvarchar(max) Variable width Unicode string 536,870,912 characters
ntext Variable width Unicode string 2GB of text data
binary(n) Fixed width binary string 8,000 bytes
varbinary Variable width binary string 8,000 bytes
varbinary(max) Variable width binary string 2GB
image Variable width binary string 2GB
Numeric Data Types
Data type Description Storage
bit Integer that can be 0, 1, or NULL
tinyint Allows whole numbers from 0 to 255 1 byte
smallint Allows whole numbers between -32,768 and
32,767
2 bytes
int Allows whole numbers between -2,147,483,648
and 2,147,483,647
4 bytes
bigint Allows whole numbers between -
9,223,372,036,854,775,808 and
9,223,372,036,854,775,807
8 bytes
decimal(p,s) Fixed precision and scale numbers.
Allows numbers from -10^38 +1 to 10^38 –1.
The p parameter indicates precision. p must be a
value from 1 to 38. Default is 18.
The s parameter indicates scale. s must be a value
from 0 to p. Default value is 0
5-17 bytes
numeric(p,s) Fixed precision and scale numbers.
Allows numbers from -10^38 +1 to
10^38 –1.
The p parameter indicates precision. p
must be a value from 1 to 38. Default is
18.
The s parameter indicates scale. s must
be a value from 0 to p. Default value is 0
5-17 bytes
smallmoney Monetary data from -214,748.3648 to
214,748.3647
4 bytes
money Monetary data from -
922,337,203,685,477.5808 to
922,337,203,685,477.5807
8 bytes
float(n) Floating precision number data from -
1.79E + 308 to 1.79E + 308.
The n parameter indicates whether the
field should hold 4 or 8 bytes. float(24)
holds a 4-byte field and float(53) holds
an 8-byte field. Default value of n is 53.
4 or 8 bytes
real Floating precision number data from -
3.40E + 38 to 3.40E + 38
4 bytes
Date and Time Data Types
Data type Description Storage
datetime From January 1, 1753 to December 31, 9999 with an accuracy of 3.33 milliseconds 8 bytes
datetime2 From January 1, 0001 to December 31, 9999 with an accuracy of 100 nanoseconds 6-8 bytes
smalldatetime From January 1, 1900 to June 6, 2079 with an accuracy of 1 minute 4 bytes
date Store a date only. From January 1, 0001 to December 31, 9999 3 bytes
time Store a time only to an accuracy of 100 nanoseconds 3-5 bytes
datetimeoffset The same as datetime2 with the addition of a time zone offset 8-10 bytes
timestamp Stores a unique number that gets updated every time a row gets created or modified. The
timestamp value is based upon an internal clock and does not correspond to real time.
Each table may have only one timestamp variable
Structured Query Language
CONSTRAINTS
Constraints
 NOT NULL
UNIQUE
PRIMARY KEY - NUT NULL + UNIQUE (Parent Table)
FOREIGN KEY (Child Table)
CHECK
DEFAULT
 INDEX
NOT NULL Constraint
CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255) NOT NULL,
Age int
)
UNIQUE Constraint
CREATE TABLE Persons (
ID int NOT NULL UNIQUE,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int
)
ID
11
12
13
14
ID
11
12
11
13
PRIMARY KEY Constraint
CREATE TABLE Persons (
ID int PRIMARY KEY,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int
)
PersonID FirstName LastNam
e
City Count
ry
P1 Will Kendy NYC US
P2 Mike Lauren NJ US
P3 Will Kendy Edison US
FOREIGN KEY Constraint
CREATE TABLE Orders (
OrderID
int NOT NULL PRIMARY KEY,
OrderNumber int NOT NULL,
PersonID
int FOREIGN KEY REFERENCES
Persons(PersonID)
)
PersonID FirstName LastName City Country
OrderID InvoiceN
um
PersonID
Primary
Key
Primary
Key
Foreign
Key
CHECK Constraint
CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int CHECK (Age>=18)
)
CREATE TABLE PersonsTest (
ID int NOT NULL primary key,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
City varchar(255),
CONSTRAINT CHK_Person CHECK (Age>=18 AND datalength(City)>3)
)
DEFAULT Constraint
CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
City varchar(255) DEFAULT 'Sandnes'
);
Indexes
 Clustered Index
 Non-Clustered Index
 Only one Clustered index in a table (with PK)
A table can have one or more non-clustered indexes and each non-clustered
index may include one or more columns of the table
Create Index
 CREATE CLUSTERED/NONCLUSTERED INDEX index_name
ON table_name (column_list)
 NONCLUSTERED is the default index
Both Clustered & Non-Clustered Index can be made UNIQUE
CREATE INDEX Statement
CREATE INDEX index_name
ON table_name (column1, column2, ...)
CREATE UNIQUE INDEX index_name
ON table_name (column1, column2, ...)
CREATE INDEX idx_lastname
ON Persons (LastName)
Drop Index idx_name
On tablename
Select Query
SELECT * FROM table_name
SELECT column1, column2, ...
FROM table_name
Select Query With Where Clause
SELECT column1, column2, ...
FROM table_name
WHERE condition
Example :
SELECT * FROM Customers
Where City='Boston’
SELECT * FROM Customers
WHERE ID=1
Select Query With Where Clause
Operator Description Example
= Equal City='Boston’
> Greater than [Shipping Fee]>100
< Less than [Shipping Fee]<100
>= Greater than or equal [Shipping Fee]>=100
<= Less than or equal [Shipping Fee]<=100
<> Not equal City<>'Boston’
Select Query With Order By
SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC
SELECT * FROM Customers
ORDER BY City
ASCENDING is the default order
Select Query With DISTINCT
SELECT DISTINCT column1, column2, ...
FROM table_name;
SELECT distinct City FROM Customers
AND, OR and NOT Operators
SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3 ...
SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...
SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;
Predicates
Predicate Description Example
BETWEEN Between a certain range Price BETWEEN 50 AND 60
LIKE Search for a pattern City LIKE 's%'
IN To specify multiple possible values
for a column
City IN ('Paris','London')
IS NULL If Selected column has blank rows Address IS NULL
IS NOT NULL IF the row is not blank in that
column
Address IS NOT NULL
Aliases
SELECT CustomerID AS ID, CustomerName AS Customer
FROM Customers
SELECT [first name] + ',' + [Last name] as CustName
From Customers
SELECT o.[Order ID], o.[Order Date], c.[First Name]FROM
Customers AS c, Orders AS o
WHERE c.City like 'L%'
Group By
 Used with Aggregate Functions, to group the result set
 Different than Order By (Group By gives only distinct values)
Syntax: Example:
SELECT column_name(s) Select [Ship City], avg([shipping fee])
FROM table_name from Orders
WHERE condition Group By [Ship City]
GROUP BY column_name(s)
ORDER BY column_name(s);
Aggregate Functions
Always to be used with Group By
SELECT FUNCTION(column_name), column1, Column2…..
FROM table_name
WHERE condition
GROUP BY(column1, column2)
Functions:
• MAX()
• MIN()
• COUNT()
• SUM()
• AVG()
• FIRST()
• LAST()
SCALAR Functions
SELECT FUNCTION(column_name)
FROM table_name
WHERE condition
Functions:
• LOWER()
• UPPER()
• LEN()
• MID(column_name, Start, Length)
• ROUND(column_name, Decimals)
• GETDATE()
• FORMAT()
Having Clause
Just as Where clause, “Having” works as condition for aggregated result while Where works for raw
data
Syntax: Example:
SELECT column_name(s) Select [Ship City], avg([shipping fee])
FROM table_name from Orders
WHERE condition Group By [Ship City]
GROUP BY column_name(s) having avg([Shipping fee]) >100
HAVING condition
ORDER BY column_name(s);
Over(Partition By…)
A step forward from Group By, this function is used to portion a results set according to specified
criteria.
Used with Aggregate Functions.
Select [Ship Country/Region],[Ship City],
avg([shipping fee]) over (partition by [ship city]) as Fee
from Orders
Ranking Functions
SELECT column1, Column2…. , FUNCTION Over(Order BY Column)
FROM table_name
Functions:
• Row_Number()
• Rank()
• Dense_Rank()
• NTILE(n)
Select [first name]+ ' ' + [last name] as EmpName, salary , Region, ntile(4)
over(partition by region order by salary desc) as Rnk
from employee
UNION, INTERSECT, EXCEPT
Union =
Intersect =
Except =
JOINS
DELETE
Commands INSERT UPDATE
A JOIN clause is used to combine rows from two or more tables, based on a related column between them
JOINS
JOINS
OUTER
Left Right Full
INNER
Theta Equi Natural
CROSS SELF
OUTER JOIN
Left Outer Join (A B)
OUTER JOIN
Right Outer Join (A B)
OUTER JOIN
Full Outer Join (A B)
NATURAL INNER JOIN
Natural joins are supported in PostgreSQL, MySQL, MariaDB, SQLite, and Oracle.
However, natural joins are not supported in SQL Server (2019)
The SQL natural join is a type of equi-join that implicitly combines tables based on
columns with the same name and type. The join predicate arises implicitly by
comparing all columns in both tables that have the same column names in the
joined tables.
INNER JOIN-Theta
Theta Join allows you to merge two
tables based on the condition
represented by theta. Theta joins work
for all comparison operators. It is
denoted by symbol θ.
INNER JOIN - EQUI
EQUI Join is done when a Theta
join uses only the equivalence
condition.
CROSS JOIN
Table 1
Col A
1
2
Table 2
Col B
3
2
4
Answer
Col A Col B
1 3
1 2
1 4
2 3
2 2
2 4
SELF JOIN
 Join a table to itself
Sub Query
One Query nested inside another
Statements can be SELECT, UPDATE,INSERT or
DELETE
Subqueries can be nested
Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name <OPERATOR>
(SELECT column_name FROM table_name WHERE condition)
Sub Query
Keywords
In place of an
expression
With IN or NOT
IN
With ANY or ALL
With EXISTS or
NOT EXISTS
In UPDATE,
DELETE, or
INSERT statement
In the FROM
clause
Views
Named Query
Advantages
Security
Simplicity
Consistency
Creating Views
CREATE/ALTER VIEW <View Name>
AS
<Query>
Select * from <View Name>
ROLES
 To easily manage the permissions in your databases, SQL Server provides
several roles which are security principals that group other principals. They are
like groups in the Microsoft Windows operating system
 There are two types of roles
- Server Level
- Application Level
Server Roles
 Sysadmin -if a login is a member of this role, it can do anything within the SQL Server
 Bulkadmin -This role allows the import of data from external files
 Dbcreator - This role allows creation of databases within SQL Server
 Diskadmin - This role allows management of backup devices, which aren't used very much in SQL Server any
more
 Processadmin - This is a powerful role because it can kill connections to SQL Server. Should be used rarely
 Securityadmin- This role controls logins for SQL Server
 Serveradmin - This role manages the SQL Server configuration
 Setupadmin - Setup admin basically gives control over linked servers
Thank You!
For any further queries, please connect us at +91-9555115533 or email us at
partner@edu4sure.com
Know us more at www.edu4sure.com
You can also check our Self-paced courses at www.testformula.com
1 of 78

Recommended

Estimating Future Initial Margin with Machine Learning by
Estimating Future Initial Margin with Machine LearningEstimating Future Initial Margin with Machine Learning
Estimating Future Initial Margin with Machine LearningAndres Hernandez
1.2K views31 slides
2013 07 Transaction Isolation Level by
2013 07 Transaction Isolation Level2013 07 Transaction Isolation Level
2013 07 Transaction Isolation LevelHung-Wei Liu
1.2K views31 slides
SoC FPGA Technology by
SoC FPGA TechnologySoC FPGA Technology
SoC FPGA TechnologySiraj Muhammad
4.2K views34 slides
Prinecomi lectureppt ch02 by
Prinecomi lectureppt ch02Prinecomi lectureppt ch02
Prinecomi lectureppt ch02rsvanwassenhove
2.5K views63 slides
Sql server ___________session_17(indexes) by
Sql server  ___________session_17(indexes)Sql server  ___________session_17(indexes)
Sql server ___________session_17(indexes)Ehtisham Ali
303 views58 slides
Oracle SQL Advanced by
Oracle SQL AdvancedOracle SQL Advanced
Oracle SQL AdvancedDhananjay Goel
331 views86 slides

More Related Content

What's hot

MEC Corporate Overview by
MEC Corporate OverviewMEC Corporate Overview
MEC Corporate OverviewDave li
441 views35 slides
Introduction To Oracle Sql by
Introduction To Oracle SqlIntroduction To Oracle Sql
Introduction To Oracle SqlAhmed Yaseen
3.1K views53 slides
07. PCA by
07. PCA07. PCA
07. PCAJeonghun Yoon
2.9K views47 slides
Linked Open Data Utrecht University Library by
Linked Open Data Utrecht University LibraryLinked Open Data Utrecht University Library
Linked Open Data Utrecht University LibraryRuben Schalk
227 views37 slides
Digital logic circuit by
Digital logic circuitDigital logic circuit
Digital logic circuitAhmedabad Institute of technology
840 views36 slides
Logic families(unit 4) by
Logic families(unit 4)Logic families(unit 4)
Logic families(unit 4)SURBHI SAROHA
199 views40 slides

What's hot(12)

Similar to Structured Query Language (SQL) _ Edu4Sure Training.pptx

Sql and mysql database concepts by
Sql and mysql database conceptsSql and mysql database concepts
Sql and mysql database conceptsSelamawit Feleke
444 views20 slides
2018 02 20_biological_databases_part2_v_upload by
2018 02 20_biological_databases_part2_v_upload2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_uploadProf. Wim Van Criekinge
1.3K views55 slides
Sql Server Interview Question by
Sql Server Interview QuestionSql Server Interview Question
Sql Server Interview Questionpukal rani
527 views37 slides
SQL (Basic to Intermediate Customized 8 Hours) by
SQL (Basic to Intermediate Customized 8 Hours)SQL (Basic to Intermediate Customized 8 Hours)
SQL (Basic to Intermediate Customized 8 Hours)Edu4Sure
88 views70 slides
Sqlmaterial 120414024230-phpapp01 by
Sqlmaterial 120414024230-phpapp01Sqlmaterial 120414024230-phpapp01
Sqlmaterial 120414024230-phpapp01Lalit009kumar
239 views78 slides
Sql Basics And Advanced by
Sql Basics And AdvancedSql Basics And Advanced
Sql Basics And Advancedrainynovember12
7.8K views41 slides

Similar to Structured Query Language (SQL) _ Edu4Sure Training.pptx(20)

Sql Server Interview Question by pukal rani
Sql Server Interview QuestionSql Server Interview Question
Sql Server Interview Question
pukal rani527 views
SQL (Basic to Intermediate Customized 8 Hours) by Edu4Sure
SQL (Basic to Intermediate Customized 8 Hours)SQL (Basic to Intermediate Customized 8 Hours)
SQL (Basic to Intermediate Customized 8 Hours)
Edu4Sure88 views
Sqlmaterial 120414024230-phpapp01 by Lalit009kumar
Sqlmaterial 120414024230-phpapp01Sqlmaterial 120414024230-phpapp01
Sqlmaterial 120414024230-phpapp01
Lalit009kumar239 views
T-SQL Overview by Ahmed Elbaz
T-SQL OverviewT-SQL Overview
T-SQL Overview
Ahmed Elbaz8.1K views
OVERVIEW OF NEW SQL,COMPARING SQL,NOSQL AND NEWSQL,B.Vinithamani,II-M.sc(Comp... by vinithabalasubramani1
OVERVIEW OF NEW SQL,COMPARING SQL,NOSQL AND NEWSQL,B.Vinithamani,II-M.sc(Comp...OVERVIEW OF NEW SQL,COMPARING SQL,NOSQL AND NEWSQL,B.Vinithamani,II-M.sc(Comp...
OVERVIEW OF NEW SQL,COMPARING SQL,NOSQL AND NEWSQL,B.Vinithamani,II-M.sc(Comp...
A tour of Amazon Redshift by Kel Graham
A tour of Amazon RedshiftA tour of Amazon Redshift
A tour of Amazon Redshift
Kel Graham6.6K views
Sql server lesson5 by Ala Qunaibi
Sql server lesson5Sql server lesson5
Sql server lesson5
Ala Qunaibi114 views
Sql tutorial by Axmed Mo.
Sql tutorialSql tutorial
Sql tutorial
Axmed Mo.913 views
Physical elements of data by Dimara Hakim
Physical elements of dataPhysical elements of data
Physical elements of data
Dimara Hakim530 views

More from Edu4Sure

Market Research using SPSS _ Edu4Sure Sept 2023.ppt by
Market Research using SPSS _ Edu4Sure Sept 2023.pptMarket Research using SPSS _ Edu4Sure Sept 2023.ppt
Market Research using SPSS _ Edu4Sure Sept 2023.pptEdu4Sure
341 views56 slides
Seo tips continue 1 to 1 live by
Seo tips continue 1 to 1 liveSeo tips continue 1 to 1 live
Seo tips continue 1 to 1 liveEdu4Sure
112 views62 slides
Marketing concepts by
Marketing conceptsMarketing concepts
Marketing conceptsEdu4Sure
188 views20 slides
Edu4Sure - Entrepreneurship by
Edu4Sure - EntrepreneurshipEdu4Sure - Entrepreneurship
Edu4Sure - EntrepreneurshipEdu4Sure
61 views24 slides
Edu4Sure - Instagram by
Edu4Sure - InstagramEdu4Sure - Instagram
Edu4Sure - InstagramEdu4Sure
311 views13 slides
Edu4Sure - Affiliate Marketing by
Edu4Sure - Affiliate MarketingEdu4Sure - Affiliate Marketing
Edu4Sure - Affiliate MarketingEdu4Sure
266 views21 slides

More from Edu4Sure(20)

Market Research using SPSS _ Edu4Sure Sept 2023.ppt by Edu4Sure
Market Research using SPSS _ Edu4Sure Sept 2023.pptMarket Research using SPSS _ Edu4Sure Sept 2023.ppt
Market Research using SPSS _ Edu4Sure Sept 2023.ppt
Edu4Sure341 views
Seo tips continue 1 to 1 live by Edu4Sure
Seo tips continue 1 to 1 liveSeo tips continue 1 to 1 live
Seo tips continue 1 to 1 live
Edu4Sure112 views
Marketing concepts by Edu4Sure
Marketing conceptsMarketing concepts
Marketing concepts
Edu4Sure188 views
Edu4Sure - Entrepreneurship by Edu4Sure
Edu4Sure - EntrepreneurshipEdu4Sure - Entrepreneurship
Edu4Sure - Entrepreneurship
Edu4Sure61 views
Edu4Sure - Instagram by Edu4Sure
Edu4Sure - InstagramEdu4Sure - Instagram
Edu4Sure - Instagram
Edu4Sure311 views
Edu4Sure - Affiliate Marketing by Edu4Sure
Edu4Sure - Affiliate MarketingEdu4Sure - Affiliate Marketing
Edu4Sure - Affiliate Marketing
Edu4Sure266 views
Edu4Sure - YouTube by Edu4Sure
Edu4Sure - YouTubeEdu4Sure - YouTube
Edu4Sure - YouTube
Edu4Sure135 views
Edu4Sure - Web Analytics (Google) by Edu4Sure
Edu4Sure - Web Analytics (Google)Edu4Sure - Web Analytics (Google)
Edu4Sure - Web Analytics (Google)
Edu4Sure103 views
Edu4Sure - Google AdSense by Edu4Sure
Edu4Sure - Google AdSenseEdu4Sure - Google AdSense
Edu4Sure - Google AdSense
Edu4Sure168 views
Edu4Sure - Power BI (MS Analytics Tool) by Edu4Sure
Edu4Sure - Power BI (MS Analytics Tool)Edu4Sure - Power BI (MS Analytics Tool)
Edu4Sure - Power BI (MS Analytics Tool)
Edu4Sure84 views
Edu4Sure - WordPress by Edu4Sure
Edu4Sure - WordPressEdu4Sure - WordPress
Edu4Sure - WordPress
Edu4Sure68 views
Edu4Sure - Google Ads Mistakes by Edu4Sure
Edu4Sure - Google Ads MistakesEdu4Sure - Google Ads Mistakes
Edu4Sure - Google Ads Mistakes
Edu4Sure99 views
Edu4Sure - LinkedIn by Edu4Sure
Edu4Sure - LinkedInEdu4Sure - LinkedIn
Edu4Sure - LinkedIn
Edu4Sure140 views
Edu4Sure - Social Media Marketing Powerfil Month Tips by Edu4Sure
Edu4Sure - Social Media Marketing Powerfil Month TipsEdu4Sure - Social Media Marketing Powerfil Month Tips
Edu4Sure - Social Media Marketing Powerfil Month Tips
Edu4Sure106 views
Edu4Sure - eMail Marketing (Mailchimp) by Edu4Sure
Edu4Sure - eMail Marketing (Mailchimp)Edu4Sure - eMail Marketing (Mailchimp)
Edu4Sure - eMail Marketing (Mailchimp)
Edu4Sure80 views
Edu4Sure - Google Ads Fundamentals by Edu4Sure
Edu4Sure - Google Ads FundamentalsEdu4Sure - Google Ads Fundamentals
Edu4Sure - Google Ads Fundamentals
Edu4Sure454 views
Edu4Sure - SEO SMO SMM by Edu4Sure
Edu4Sure - SEO SMO SMMEdu4Sure - SEO SMO SMM
Edu4Sure - SEO SMO SMM
Edu4Sure362 views
Edu4Sure - Quora by Edu4Sure
Edu4Sure - QuoraEdu4Sure - Quora
Edu4Sure - Quora
Edu4Sure96 views
Edu4Sure - Google AdWords / PPC by Edu4Sure
Edu4Sure - Google AdWords / PPCEdu4Sure - Google AdWords / PPC
Edu4Sure - Google AdWords / PPC
Edu4Sure186 views
Edu4Sure - Digital Marketing Basic Idea by Edu4Sure
Edu4Sure - Digital Marketing Basic IdeaEdu4Sure - Digital Marketing Basic Idea
Edu4Sure - Digital Marketing Basic Idea
Edu4Sure169 views

Recently uploaded

Class 10 English notes 23-24.pptx by
Class 10 English notes 23-24.pptxClass 10 English notes 23-24.pptx
Class 10 English notes 23-24.pptxTARIQ KHAN
131 views53 slides
The basics - information, data, technology and systems.pdf by
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdfJonathanCovena1
115 views1 slide
MercerJesse2.1Doc.pdf by
MercerJesse2.1Doc.pdfMercerJesse2.1Doc.pdf
MercerJesse2.1Doc.pdfjessemercerail
169 views5 slides
GSoC 2024 by
GSoC 2024GSoC 2024
GSoC 2024DeveloperStudentClub10
79 views15 slides
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively by
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyPECB
585 views18 slides
UWP OA Week Presentation (1).pptx by
UWP OA Week Presentation (1).pptxUWP OA Week Presentation (1).pptx
UWP OA Week Presentation (1).pptxJisc
88 views11 slides

Recently uploaded(20)

Class 10 English notes 23-24.pptx by TARIQ KHAN
Class 10 English notes 23-24.pptxClass 10 English notes 23-24.pptx
Class 10 English notes 23-24.pptx
TARIQ KHAN131 views
The basics - information, data, technology and systems.pdf by JonathanCovena1
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdf
JonathanCovena1115 views
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively by PECB
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
PECB 585 views
UWP OA Week Presentation (1).pptx by Jisc
UWP OA Week Presentation (1).pptxUWP OA Week Presentation (1).pptx
UWP OA Week Presentation (1).pptx
Jisc88 views
Narration ppt.pptx by TARIQ KHAN
Narration  ppt.pptxNarration  ppt.pptx
Narration ppt.pptx
TARIQ KHAN135 views
Scope of Biochemistry.pptx by shoba shoba
Scope of Biochemistry.pptxScope of Biochemistry.pptx
Scope of Biochemistry.pptx
shoba shoba133 views
11.28.23 Social Capital and Social Exclusion.pptx by mary850239
11.28.23 Social Capital and Social Exclusion.pptx11.28.23 Social Capital and Social Exclusion.pptx
11.28.23 Social Capital and Social Exclusion.pptx
mary850239298 views
AUDIENCE - BANDURA.pptx by iammrhaywood
AUDIENCE - BANDURA.pptxAUDIENCE - BANDURA.pptx
AUDIENCE - BANDURA.pptx
iammrhaywood84 views
11.30.23 Poverty and Inequality in America.pptx by mary850239
11.30.23 Poverty and Inequality in America.pptx11.30.23 Poverty and Inequality in America.pptx
11.30.23 Poverty and Inequality in America.pptx
mary850239160 views
REPRESENTATION - GAUNTLET.pptx by iammrhaywood
REPRESENTATION - GAUNTLET.pptxREPRESENTATION - GAUNTLET.pptx
REPRESENTATION - GAUNTLET.pptx
iammrhaywood100 views
PLASMA PROTEIN (2).pptx by MEGHANA C
PLASMA PROTEIN (2).pptxPLASMA PROTEIN (2).pptx
PLASMA PROTEIN (2).pptx
MEGHANA C68 views
Are we onboard yet University of Sussex.pptx by Jisc
Are we onboard yet University of Sussex.pptxAre we onboard yet University of Sussex.pptx
Are we onboard yet University of Sussex.pptx
Jisc96 views
AI Tools for Business and Startups by Svetlin Nakov
AI Tools for Business and StartupsAI Tools for Business and Startups
AI Tools for Business and Startups
Svetlin Nakov107 views
Psychology KS5 by WestHatch
Psychology KS5Psychology KS5
Psychology KS5
WestHatch93 views
The Accursed House by Émile Gaboriau by DivyaSheta
The Accursed House  by Émile GaboriauThe Accursed House  by Émile Gaboriau
The Accursed House by Émile Gaboriau
DivyaSheta201 views
Sociology KS5 by WestHatch
Sociology KS5Sociology KS5
Sociology KS5
WestHatch70 views

Structured Query Language (SQL) _ Edu4Sure Training.pptx

  • 2. Introduction  SQL is a standard language for storing, manipulating and retrieving data in database  Same language can be used to query data in MySQL, SQL Server, MS Access, Oracle, Sybase, Informix, Postgres, and other database systems
  • 3. Why SQL?  Universal Language  Open Source - Easy to Learn & Use  Manage Million Rows of Data  High in Demand
  • 4. Data, Datasets And Database Data • Data are observations or measurements (unprocessed or processed) represented as text, numbers, or multimedia • Example: Details of employees like Name, Age, Town, etc. written Dataset • A dataset is a structured collection of data generally associated with a unique body of work • Example: Details of employees of one town organized alphabetically Database • A database is an organized collection of data stored as multiple datasets • Example: Alphabetically arranged details of all the employees from all the towns, stored in an electronic unit
  • 5. Why Database?  Need of Hour for every business – small or big  Manage vast volumes of data  Keeps your data safe & secure  Make meaningful decisions  Manipulate & update data
  • 6. Understanding Database  A database is an organized collection of information or data  A database is stored in an electronic storage  Databases makes management of data easy
  • 7. Relational Database • Stores data in form of tables • Tables can be connected or related to each other based on common data • Supports SQL for querying
  • 8. Use Case: Data Fetching Process Database API Web Access Any Program Application Programming Interface
  • 9. Data Normalization  Data normalization is generally considered the development of clean data  Eliminating unstructured data and redundancy (duplicates) in order to ensure logical data storage
  • 10. Data Normalization - 3 Normal Forms 1 NF • Each entry must have only one single value for each cell • Each record must be unique 2 NF • Data must have only one Primary Key • Then, relationships can be created through new foreign key labels 3 NF • Data in a table must only be dependent on the primary key • If the primary key is changed, all data that is impacted must be put into a new table
  • 11. Constraints Related to Data Normalization  Primary Key (Parent Table, Referenced Table)  Foreign Key (Child Table)  Composite Key  Example on the Next Page
  • 12. PersonID LastName FirstName Age 1 Hansen Ola 30 2 Svendson Tove 23 3 Pettersen Kari 20 Persons Table Orders Table OrderID OrderNumber PersonID 1 77895 3 2 44678 3 3 22456 2 4 24562 1  Notice that the "PersonID" column in the "Orders" table points to the "PersonID" column in the "Persons" table  The "PersonID" column in the "Persons" table is the PRIMARY KEY in the "Persons" table  The "PersonID" column in the "Orders" table is a FOREIGN KEY in the "Orders" table  The FOREIGN KEY constraint prevents invalid data from being inserted into the foreign key column, because it has to be one of the values contained in the parent table
  • 13.  A composite key is made by the combination of two or more columns in a table that can be used to uniquely identify each row in the table when the columns are combined uniqueness of a row is guaranteed, but when it is taken individually it does not guarantee uniqueness.  It can also be understood as a primary key made by the combination of two or more attributes to uniquely identify every row in a table.
  • 14. ER Diagram It displays the relationship of entity sets stored in a database.
  • 15. What is Schema  A schema is a list of logical structures of data.  Three Types o Logical Schema: ER Diagram o Physical Schema: The Physical Schemas shows the databases and the objects that they contain. This tells how the data will be stored in the storage device. o View Schema: It shows only those data to a view group in which they are interested and hides the remaining details from them.
  • 16. DATABASE TRANSACTION MODELS  ACID Model (Atomic, Consistent, Isolated, Durable)  BASE Model (Basically Available, Soft State, Eventually Consistent) Deciding on the right database management system
  • 17. ACID Database Model • Atomic – Each transaction is either properly carried out or the process halts and the database reverts back to the state before the transaction started. This ensures that all data in the database is valid. • Consistent – A processed transaction will never endanger the structural integrity of the database. • Isolated – Transactions cannot compromise the integrity of other transactions by interacting with them while they are still in progress. • Durable – The data related to the completed transaction will persist even in the cases of network or power outages. If a transaction fails, it will not impact the manipulated data.
  • 18. BASE Database Model • Basically Available – Rather than enforcing immediate consistency, BASE-modelled NoSQL databases will ensure availability of data by spreading and replicating it across the nodes of the database cluster. • Soft State – Due to the lack of immediate consistency, data values may change over time. The BASE model breaks off with the concept of a database which enforces its own consistency, delegating that responsibility to developers. • Eventually Consistent – The fact that BASE does not enforce immediate consistency does not mean that it never achieves it. However, until it does, data reads are still possible (even though they might not reflect the reality).
  • 19. Which Databases are ACID compliant? Relational database management system MySQL PostgreSQL Oracle SQLite Microsoft SQL Server
  • 20. Which Databases are BASE compliant?  NoSQL databases  MongoDB  Cassandra  Redis  Amazon DynamoDB  Couchbase
  • 21. Use Case Examples  ACID: Money transfers  BASE: Social network feeds
  • 22. SQL Commands DDL – Data Definition Language DML – Data Manipulation Language DCL – Data Control Language TCL – Transaction Control Language DQL- Data Query Language
  • 28. Naming Connotations  tbl_: Table  PK_: Primary Key  vw_: View  ix_: Index  clix_: Clustered Index
  • 32. Data Types (String) Data Type Description Max Size Storage char(n) Fixed width character string 8,000 characters Defined width varchar(n) Variable width character string 8,000 characters 2 bytes + number of chars varchar(max) Variable width character string 1,073,741,824 characters 2 bytes + number of chars text Variable width character string 2GB of text data 4 bytes + number of chars nchar Fixed width Unicode string 4,000 characters Defined width x 2 nvarchar Variable width Unicode string 4,000 characters nvarchar(max) Variable width Unicode string 536,870,912 characters ntext Variable width Unicode string 2GB of text data binary(n) Fixed width binary string 8,000 bytes varbinary Variable width binary string 8,000 bytes varbinary(max) Variable width binary string 2GB image Variable width binary string 2GB
  • 33. Numeric Data Types Data type Description Storage bit Integer that can be 0, 1, or NULL tinyint Allows whole numbers from 0 to 255 1 byte smallint Allows whole numbers between -32,768 and 32,767 2 bytes int Allows whole numbers between -2,147,483,648 and 2,147,483,647 4 bytes bigint Allows whole numbers between - 9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 8 bytes decimal(p,s) Fixed precision and scale numbers. Allows numbers from -10^38 +1 to 10^38 –1. The p parameter indicates precision. p must be a value from 1 to 38. Default is 18. The s parameter indicates scale. s must be a value from 0 to p. Default value is 0 5-17 bytes numeric(p,s) Fixed precision and scale numbers. Allows numbers from -10^38 +1 to 10^38 –1. The p parameter indicates precision. p must be a value from 1 to 38. Default is 18. The s parameter indicates scale. s must be a value from 0 to p. Default value is 0 5-17 bytes smallmoney Monetary data from -214,748.3648 to 214,748.3647 4 bytes money Monetary data from - 922,337,203,685,477.5808 to 922,337,203,685,477.5807 8 bytes float(n) Floating precision number data from - 1.79E + 308 to 1.79E + 308. The n parameter indicates whether the field should hold 4 or 8 bytes. float(24) holds a 4-byte field and float(53) holds an 8-byte field. Default value of n is 53. 4 or 8 bytes real Floating precision number data from - 3.40E + 38 to 3.40E + 38 4 bytes
  • 34. Date and Time Data Types Data type Description Storage datetime From January 1, 1753 to December 31, 9999 with an accuracy of 3.33 milliseconds 8 bytes datetime2 From January 1, 0001 to December 31, 9999 with an accuracy of 100 nanoseconds 6-8 bytes smalldatetime From January 1, 1900 to June 6, 2079 with an accuracy of 1 minute 4 bytes date Store a date only. From January 1, 0001 to December 31, 9999 3 bytes time Store a time only to an accuracy of 100 nanoseconds 3-5 bytes datetimeoffset The same as datetime2 with the addition of a time zone offset 8-10 bytes timestamp Stores a unique number that gets updated every time a row gets created or modified. The timestamp value is based upon an internal clock and does not correspond to real time. Each table may have only one timestamp variable
  • 36. Constraints  NOT NULL UNIQUE PRIMARY KEY - NUT NULL + UNIQUE (Parent Table) FOREIGN KEY (Child Table) CHECK DEFAULT  INDEX
  • 37. NOT NULL Constraint CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255) NOT NULL, Age int )
  • 38. UNIQUE Constraint CREATE TABLE Persons ( ID int NOT NULL UNIQUE, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int ) ID 11 12 13 14 ID 11 12 11 13
  • 39. PRIMARY KEY Constraint CREATE TABLE Persons ( ID int PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int ) PersonID FirstName LastNam e City Count ry P1 Will Kendy NYC US P2 Mike Lauren NJ US P3 Will Kendy Edison US
  • 40. FOREIGN KEY Constraint CREATE TABLE Orders ( OrderID int NOT NULL PRIMARY KEY, OrderNumber int NOT NULL, PersonID int FOREIGN KEY REFERENCES Persons(PersonID) ) PersonID FirstName LastName City Country OrderID InvoiceN um PersonID Primary Key Primary Key Foreign Key
  • 41. CHECK Constraint CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int CHECK (Age>=18) ) CREATE TABLE PersonsTest ( ID int NOT NULL primary key, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, City varchar(255), CONSTRAINT CHK_Person CHECK (Age>=18 AND datalength(City)>3) )
  • 42. DEFAULT Constraint CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, City varchar(255) DEFAULT 'Sandnes' );
  • 43. Indexes  Clustered Index  Non-Clustered Index  Only one Clustered index in a table (with PK) A table can have one or more non-clustered indexes and each non-clustered index may include one or more columns of the table
  • 44. Create Index  CREATE CLUSTERED/NONCLUSTERED INDEX index_name ON table_name (column_list)  NONCLUSTERED is the default index Both Clustered & Non-Clustered Index can be made UNIQUE
  • 45. CREATE INDEX Statement CREATE INDEX index_name ON table_name (column1, column2, ...) CREATE UNIQUE INDEX index_name ON table_name (column1, column2, ...) CREATE INDEX idx_lastname ON Persons (LastName) Drop Index idx_name On tablename
  • 46. Select Query SELECT * FROM table_name SELECT column1, column2, ... FROM table_name
  • 47. Select Query With Where Clause SELECT column1, column2, ... FROM table_name WHERE condition Example : SELECT * FROM Customers Where City='Boston’ SELECT * FROM Customers WHERE ID=1
  • 48. Select Query With Where Clause Operator Description Example = Equal City='Boston’ > Greater than [Shipping Fee]>100 < Less than [Shipping Fee]<100 >= Greater than or equal [Shipping Fee]>=100 <= Less than or equal [Shipping Fee]<=100 <> Not equal City<>'Boston’
  • 49. Select Query With Order By SELECT column1, column2, ... FROM table_name ORDER BY column1, column2, ... ASC|DESC SELECT * FROM Customers ORDER BY City ASCENDING is the default order
  • 50. Select Query With DISTINCT SELECT DISTINCT column1, column2, ... FROM table_name; SELECT distinct City FROM Customers
  • 51. AND, OR and NOT Operators SELECT column1, column2, ... FROM table_name WHERE condition1 AND condition2 AND condition3 ... SELECT column1, column2, ... FROM table_name WHERE condition1 OR condition2 OR condition3 ... SELECT column1, column2, ... FROM table_name WHERE NOT condition;
  • 52. Predicates Predicate Description Example BETWEEN Between a certain range Price BETWEEN 50 AND 60 LIKE Search for a pattern City LIKE 's%' IN To specify multiple possible values for a column City IN ('Paris','London') IS NULL If Selected column has blank rows Address IS NULL IS NOT NULL IF the row is not blank in that column Address IS NOT NULL
  • 53. Aliases SELECT CustomerID AS ID, CustomerName AS Customer FROM Customers SELECT [first name] + ',' + [Last name] as CustName From Customers SELECT o.[Order ID], o.[Order Date], c.[First Name]FROM Customers AS c, Orders AS o WHERE c.City like 'L%'
  • 54. Group By  Used with Aggregate Functions, to group the result set  Different than Order By (Group By gives only distinct values) Syntax: Example: SELECT column_name(s) Select [Ship City], avg([shipping fee]) FROM table_name from Orders WHERE condition Group By [Ship City] GROUP BY column_name(s) ORDER BY column_name(s);
  • 55. Aggregate Functions Always to be used with Group By SELECT FUNCTION(column_name), column1, Column2….. FROM table_name WHERE condition GROUP BY(column1, column2) Functions: • MAX() • MIN() • COUNT() • SUM() • AVG() • FIRST() • LAST()
  • 56. SCALAR Functions SELECT FUNCTION(column_name) FROM table_name WHERE condition Functions: • LOWER() • UPPER() • LEN() • MID(column_name, Start, Length) • ROUND(column_name, Decimals) • GETDATE() • FORMAT()
  • 57. Having Clause Just as Where clause, “Having” works as condition for aggregated result while Where works for raw data Syntax: Example: SELECT column_name(s) Select [Ship City], avg([shipping fee]) FROM table_name from Orders WHERE condition Group By [Ship City] GROUP BY column_name(s) having avg([Shipping fee]) >100 HAVING condition ORDER BY column_name(s);
  • 58. Over(Partition By…) A step forward from Group By, this function is used to portion a results set according to specified criteria. Used with Aggregate Functions. Select [Ship Country/Region],[Ship City], avg([shipping fee]) over (partition by [ship city]) as Fee from Orders
  • 59. Ranking Functions SELECT column1, Column2…. , FUNCTION Over(Order BY Column) FROM table_name Functions: • Row_Number() • Rank() • Dense_Rank() • NTILE(n) Select [first name]+ ' ' + [last name] as EmpName, salary , Region, ntile(4) over(partition by region order by salary desc) as Rnk from employee
  • 60. UNION, INTERSECT, EXCEPT Union = Intersect = Except =
  • 61. JOINS DELETE Commands INSERT UPDATE A JOIN clause is used to combine rows from two or more tables, based on a related column between them
  • 63. OUTER JOIN Left Outer Join (A B)
  • 65. OUTER JOIN Full Outer Join (A B)
  • 66. NATURAL INNER JOIN Natural joins are supported in PostgreSQL, MySQL, MariaDB, SQLite, and Oracle. However, natural joins are not supported in SQL Server (2019) The SQL natural join is a type of equi-join that implicitly combines tables based on columns with the same name and type. The join predicate arises implicitly by comparing all columns in both tables that have the same column names in the joined tables.
  • 67. INNER JOIN-Theta Theta Join allows you to merge two tables based on the condition represented by theta. Theta joins work for all comparison operators. It is denoted by symbol θ.
  • 68. INNER JOIN - EQUI EQUI Join is done when a Theta join uses only the equivalence condition.
  • 69. CROSS JOIN Table 1 Col A 1 2 Table 2 Col B 3 2 4 Answer Col A Col B 1 3 1 2 1 4 2 3 2 2 2 4
  • 70. SELF JOIN  Join a table to itself
  • 71. Sub Query One Query nested inside another Statements can be SELECT, UPDATE,INSERT or DELETE Subqueries can be nested
  • 72. Syntax SELECT column_name(s) FROM table_name WHERE column_name <OPERATOR> (SELECT column_name FROM table_name WHERE condition)
  • 73. Sub Query Keywords In place of an expression With IN or NOT IN With ANY or ALL With EXISTS or NOT EXISTS In UPDATE, DELETE, or INSERT statement In the FROM clause
  • 75. Creating Views CREATE/ALTER VIEW <View Name> AS <Query> Select * from <View Name>
  • 76. ROLES  To easily manage the permissions in your databases, SQL Server provides several roles which are security principals that group other principals. They are like groups in the Microsoft Windows operating system  There are two types of roles - Server Level - Application Level
  • 77. Server Roles  Sysadmin -if a login is a member of this role, it can do anything within the SQL Server  Bulkadmin -This role allows the import of data from external files  Dbcreator - This role allows creation of databases within SQL Server  Diskadmin - This role allows management of backup devices, which aren't used very much in SQL Server any more  Processadmin - This is a powerful role because it can kill connections to SQL Server. Should be used rarely  Securityadmin- This role controls logins for SQL Server  Serveradmin - This role manages the SQL Server configuration  Setupadmin - Setup admin basically gives control over linked servers
  • 78. Thank You! For any further queries, please connect us at +91-9555115533 or email us at partner@edu4sure.com Know us more at www.edu4sure.com You can also check our Self-paced courses at www.testformula.com

Editor's Notes

  1. Most of the companies do not incentivize their employees on their ideas and not just efforts….