You are on page 1of 19

Functional Testing

1. B
2. I
3. E
4. D/B
5. S
6. C

Database Testing

Sign Up form – Check on UI (Front End)

FN- M

LN- C

Email- CM

Mb. No-12

Address-Pune

Submit

“Sign up is successful” – we can check for success message

Database-

Customer Sign Up Table

- Validate correctness & completeness

Database/ Backend Testing

Database- storage location – collection of related data

1. Structured data- Facebook, filpkart, amazon, MSEB, MPSC, IRCTC


2. Unstructured data- Random data- social media post- Data cannot be stored in DB

Database management system (DBMS)

- To perform any operations on the data we need the DBMS


- Different database- Oracal, sql server, My Sql, MangoDB
When we deal with structured data we use RDBMS

What is SQL-

SQL – Structured Query Language

It is designed for managing data in a RDBMS

Pronounced- SQL or See-Qwell

SQL- is a database language / not the database

SQL- used

- Database creation
- deletion
- Fetching row
- Modifying row

Why SQL is required

- To create database/table
- To insert record
- To update record
- To delete records
- To retrieve data

SQL Syntax

SQL follows some unique set of rules & regulation called syntax

SQL- is not case sensitive. Generally SQL keywords are written in Uppercase

SQL Statement

SQL statement are stared with any of the SQL command/keyword

Iike- SELECT, INSERT, UPDATE, DELETE, ALTER, DROP


Statement ends with a semicolon (;)

Ex. SELECT “Column name” FROM “table name”;

Why use semicolon?

Used to separate SQL statement

SQL Commands / Keyword

Select- extract data from the database

Update- update data in database

Delete-

Create table-

Alter table-

Drop table-

Inert in to –

SQL Commands- are instruction. It is used to communicate with the database also used to
perform specific task

Types of SQL commands

Five types of SQL commands

1. DDL- data definition language


2. DML- data manipulation language
3. DCL- data control language
4. TCL – transaction control language
5. DQL- data query language

DDL- data definition language

- Changes the structure of the table like creating a table, delete a table, altering table etc….
- All DDL command- auto committed – means – it permanently save all the changes in the
database
- DDL commands
1. Create
2. Alter
3. Drop
4. Truncate

DML- data manipulation language

- DML commands used to modify the database


- DML- not auto committed- means it can’t permanently save all the changes in the
database
- They can be rollback
- DML – commands
1. Insert
2. Update
3. Delete

Data query language

- DQL is used to fetch the data from the database/ table


- DQL command
1. Select

Database- collection of data- storage – no of table – row (records) & column (field)

Ex. Sign up, login credentials, orders, employee info, student’s registration

Table Name- Sign Up – front end- UI- ID,FN,LN,MObNo,EmailID, City- submit- successful

ID FN LN MobNo EmailId City

1 Rahul Gandhi 1111 1@gmail.com Pune

2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 Anna Hajare 3333 3@gmail.com Pune

4 Sharad Pawar 4444 4@gmail.com Baramati

5 Soniya Gandhi 5555 5@gmail.com Pune


1. SQL SELECT statement
- Fetch the data from the database
- Retrieve the data from the database
- Following sql statement selects or fetch the record in the sign up table

SELECT Syntax

SELECT * FROM tablename;

Example

SELECT * FROM SIgnUP;

Output

We get the all the records from the tables

ID FN LN MobNo EmailId City

1 Rahul Gandhi 1111 1@gmail.com Pune

2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 Anna Hajare 3333 3@gmail.com Pune

4 Sharad Pawar 4444 4@gmail.com Baramati

5 Soniya Gandhi 5555 5@gmail.com Pune

* - rows & column select

Select particular column in the table

For EX. select FN & LN column

Syntax

SELECT column1, column2….n FROM tablename;

or

SELECT column1, column2….N

FROM tablename;
Example-

SELECT FN, LN FROM SignUP;

Or

SELECT FN, LN

FROM SignUP;

Output-

FN LN

1 Rahul Gandhi

2 Arvind Kejriwal

3 Anna Hajare

4 Sharad Pawar

5 Soniya Gandhi

2. Distinct
- Keyword / statement is used to return only distinct value/ different value/ unique value in
the particular column
- Table – column- many duplicate value – sometimes we want only unique value
- Ex. LN – distinct value select

Syntax

SELECT DISTINCT column 1, 2, 3….n

FROM tablename;

Example

SELECT DISTINCT LN FROM SignUp;

Output
LN

1 Gandhi

2 Kejriwal

3 Hajare

4 Pawar

Count

Syntax

SELECT COUNT (DISTINCT column 1, 2, 3….n)

FROM tablename;

Example

SELECT COUNT (DISTINCT LN) FROM SignUp;

Output

Number of records- 4

Without Distinct

SELECT coumnname 1, 2…n FROM tablename;

Example

SELECT LN FROM SignUp;

Output

LN

1 Gandhi

2 Kejriwal

3 Hajare
4 Pawar

5 Gandhi

TOP (SQL server)

SQL statement it used to display the top records in a table

Syntax

SELECT TOP value/number/percentage * FROM tablename;

Example

SELECT TOP 3 * FROM SignUp;

SELECT TOP 50% * FROM SignUp;

Output

ID FN LN MobNo EmailId City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 3 Anna Hajare 3333 3@gmail.com Pune

RONUM(Oracal)

SELECT * FROM tablename

Where RONUM<=value;

SELECT * FROM SignUp

Where RONUM<=3;

ID FN LN MobNo EmailId City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 2 Arvind Kejriwal 2222 2@gmail.com Mumbai


3 3 Anna Hajare 3333 3@gmail.com Pune

Limit (MySql)

SELECT * FROM tablename

LIMIT value;

SELECT * FROM SignUp

LIMIT 2;

Output

ID FN LN MobNo EmailId City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

ORDER BY

Order by keyword – it used to sort the result set in ascending & descending order

It is used to display the records by ascending & descending order from selected column

Default- Ascending order

DESC- Descending order

Ascending order

SELECT * FROM tablename

ORDERBY column 1,2,3….n;


SELECT * FROM SignUp

ORDERBY FN;

ID FN LN MobNo EmailId City

1 3 Anna Hajare 3333 3@gmail.com Pune

2 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

3 1 Rahul Gandhi 1111 1@gmail.com Pune

4 4 Sharad Pawar 4444 4@gmail.com Baramati

5 5 Soniya Gandhi 5555 5@gmail.com Pune

Descending order

SELECT * FROM tablename

ORDERBY column name DESC;

SELECT * FROM SignUp

ORDERBY FN DESC;

ID FN LN MobNo EmailId City

2 5 Soniya Gandhi 5555 5@gmail.com Pune

1 4 Sharad Pawar 4444 4@gmail.com Baramati

3 1 Rahul Gandhi 1111 1@gmail.com Pune

4 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

5 3 Anna Hajare 3333 3@gmail.com Pune


Where clause

- Where clause is used to filter records


- It is used to extract only those records that fulfill a specified condition
- EX. Sign Up- City- Pune

SELECT * FROM tablename

WHERE condition;

CIndition= (Column name = value)

SELECT * FROM SignUp

WHERE City=Pune;

ID FN LN MobNo EmailId City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 3 Anna Hajare 3333 3@gmail.com Pune

3 5 Soniya Gandhi 5555 5@gmail.com Pune

SELECT * FROM tablename

WHERE Columnane=value;

SELECT * FROM SignUp

WHERE ID=1;

ID FN LN MobNo EmailId City


1 1 Rahul Gandhi 1111 1@gmail.com Pune

SELECT coulmn1 ,2,3…FROM tablename

WHERE condition;

SELECT email id FROM SignUp

WHERE City=Pune;

Email Id
1 1@gmail.com
2 3@gmail.com
3 5@gmail.com

Type of Where Clause

1. Or
2. And

Logic gates

OR- 1 1 =1 1 0 =1 0 1 =1 0 0 =0

AND- 1 1 =1 1 0 =0 0 1 =0 0 0 =0

OR-

Use to select records when both condition or one condition is true

SELECT * FROM tablename

WHERE condition 1 OR condition 2;


SELECT * FROM SignUP

WHERE FN=’Rahul’ OR LN=’Gandhi’;

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 5 Soniya Gandhi 5555 5@gmail.com Pune

SELECT column name 1,2, FROM tablename

WHERE condition 1 OR condition 2;

SELECT emaild FROM SignUp

WHERE FN=Rahul OR LN= Gandhi;

Email Id
1 1@gmail.com
2 5@gmail.com

AND

- Select records when both the condition must be true the we get the output will be true

SELECT * FROM tablename

WHERE condition 1 AND condition 2;

SELECT * FROM SignUp


WHERE FN=Rahul AND LN=Gandhi;

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 1111 1@gmail.com Pune


SELECT column 1, 2 FROM tablename

WHERE condition 1 AND condition 2;

SELECT Mob.No FROM SignUp

WHERE FN=Rahul AND LN=Gandhi;

Mob. No

1 1111

Like Operator

Start name S/B/

End Name H

Like operator it is used in a where clause to search for a specified pattern in a column

1. % -----multiple characters
2. _ ------ single character

For starting with specific alphabets

SELECT * FROM tablename

WHERE columnname LIKE pattern;

SELECT * FROM SignUp

WHERE FN LIKE ‘A%’;


ID FN LN Mob. No Email Id City

1 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

2 3 Anna Hajare 3333 3@gmail.com Pune

SELECT columnname FROM tablename

WHERE columnname LIKE pattern;

SELECT LN FROM SignUp

WHERE FN LIKE ‘A%’;

LN

1 Kejriwal

2 Hajare

For ending with specific alphabets

SELECT * FROM tablename

WHERE columnname LIKE pattern;

SELECT * FROM SignUp

WHERE FN LIKE ‘%d’;

ID FN LN Mob. No Email Id City

1 2 Arvind Kejriwal 2222 2@gmail.com Mumbai

2 4 Sharad Pawar 4444 4@gmail.com Baramati


SELECT columnname FROM tablename

WHERE columnname LIKE pattern;

SELECT LN FROM SignUp

WHERE FN LIKE ‘%d’;

LN

1 Kejriwal

2 Pawar

A%d

[ABC]%

%[ABC]

SELECT * FROM tablename

WHERE columnname NOT LIKE pattern;

SELECT * FROM SignUp

WHERE FN NOT LIKE ‘A%’;

ID FN LN Mob. No Email Id City

1 1 Rahul Gandhi 1111 1@gmail.com Pune

2 4 Sharad Pawar 4444 4@gmail.com Baramati


3 5 Soniya Gandhi 5555 5@gmail.com Pune

Select all records where the value of the column starts with the letter "A".

Syntax

SELECT * FROM table_name
WHERE column LIKE “A%”;

Select all records where the value of the column ends with the letter "a".

Syntax

SELECT * FROM table_name
WHERE column LIKE “%a”;

Select all records where the value of the column starts with letter "A" and ends with the
letter "b".

Syntax

SELECT * FROM table_name
WHERE column LIKE “A%b”;

Select all records where the value of the column contains the letter "a".

Syntax

SELECT * FROM table_name
WHERE column LIKE “%a%”;

Select all records where the value of the column does NOT start with the letter "A".
Syntax

SELECT * FROM table_name
WHERE column NOT LIKE “A%”;

For Starting with alphabets ABC

The following SQL statement selects all Sign Up with a FN starting with "A", "B", or "C":

Syntax

SELECT * FROM table_name
WHERE column LIKE “[ABC]%”;

For Ending with alphabets ABC

The following SQL statement selects all Sign Up with a FN ending with "A", "B", or "C":

Syntax

SELECT * FROM table_name
WHERE column LIKE “%[ABC]”;

LIKE Operator Description


WHERE Column LIKE 'a%' Finds any values that start with "a"
WHERE Column LIKE '%a'
Finds any values that end with "a"

WHERE Column LIKE '%or%' Finds any values that have "or" in any position
WHERE Column LIKE '_r%'
Finds any values that have "r" in the second
position

WHERE Column LIKE 'a_%'


Finds any values that start with "a" and are at
least 2 characters in length

WHERE Column LIKE 'a__%' Finds any values that start with "a" and are at
least 3 characters in length
WHERE Column LIKE 'a%o' Finds any values that start with "a" and ends
with "o"

You might also like