WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
Data base testing
1.
2. The definition of a database is a structured
collection of records or data that is stored in a
computer system. In order for a database to be
truly functional, it must not only store large
amounts of records well, but be accessed easily.
A database is a collection of information that is
organized so that it can easily be accessed,
managed, and updated.
3. Data Definition Language (DDL) statements are
used to define the database structure or schema
Data Manipulation Language (DML) statements are
used for managing data within schema objects.
They need to be committed, whereas DDL
commands are auto commit
Data Control Language (DCL) are used to configure
and control database objects.
Transaction Control (TCL) statements are used to
manage the changes made by DML statements. It
allows statements to be grouped together into
logical transactions.
4. CREATE - to create objects in the database
ALTER - alters the structure of the database
DROP - delete objects from the database
TRUNCATE - remove all records from a table,
including all spaces allocated for the records are
removed
COMMENT - add comments to the data dictionary
RENAME - rename an object
5. SELECT - retrieve data from the database
INSERT - insert data into a table
UPDATE - updates existing data within a table
DELETE - deletes all records from a table, the space
for the records remain as such
CALL - call a PL/SQL or Java subprogram
EXPLAIN PLAN - explain access path to data
LOCK TABLE - control concurrency
6. GRANT - gives user's access privileges to database
REVOKE - withdraw access privileges given with the
GRANT command
7. COMMIT - save work done
SAVEPOINT - identify a point in a transaction to
which you can later roll back
ROLLBACK - restore database to original since the
last COMMIT
SET TRANSACTION - Change transaction options
like isolation level and what rollback segment to
use
9. Insert
INSERT INTO "table_name" ("column1", "column2",
...)
VALUES ("value1", "value2", ...)
Or
INSERT INTO "table1" ("column1", "column2", ...)
SELECT "column3", "column4", ...
FROM "table2"
10. Database testing involves testing the behavior of
the database when the application is being tested.
This may involve testing to see if values are being
inserted properly, flags are changing appropriately,
validity of data, to ensure if data integrity is
maintained. It may also account for performance
related to the database. SQL queries can be fired in
the database to check if the expected results are
achieved.
11. Database testing includes the following process:
1. Data validity testing – to perform this testing, one
should be good in SQL queries
2. Data integrity testing - to perform this testing,
the referential integrity and constraints should be
known.
3. Performance testing in relation with the
database - to perform this testing, one should be
good in structure of the table and its design.
4. Procedure testing and triggers testing – to
perform this testing, one should be good enough
to understand the program and logic flow.
12. Data validity is the correctness & reasonableness of
data.
Reasonableness means, for e.g. Account number
falling within a range, numeric data being all digits,
dates having all month, days & year, and spelling
of proper names. Data validity errors are probably
the most common and most difficult to detect.
13. Data integrity refers to the wholeness or
completeness of data during operations involving
transfer, storage and retrieval. It also refers to the
preservation of data so that whatever process it
undergoes through, it will still remain to be what it
has been intended for. In other words, data
integrity is the assurance that data will always be
correct, consistent and accessible.
14. Performance of the database can be increased by:-
Design your database "properly" - a normalized
database design is usually a good starting point.
Occasionally you may have to denormalize
something, but only do so as a result of testing
showing the need, and AFTER optimizing the
database in the normalized design.
Create indexes – Index columns that are frequently
used as important selection criteria, sort criteria,
and/or used in joins.
15. Optimize your queries - While specifying the
column list as opposed to SELECT * is a best
practice, the performance impact is relatively small.
But constructing a query that returns as few rows
as possible and makes the best use of existing
indexes, etc. will make the biggest difference.
Make the database do the work - construct SQL
queries (and/or stored procedures) that deliver
data as close to your "final product" as possible.
This means that you should minimize the number
of round trips - for instance, by minimizing the
number of queries to obtain a set of data.
16. Stored procedures are precompiled database
queries that improve the security, efficiency and
usability of database client/server applications.
17. A database trigger is procedural code that is
automatically executed in response to certain
events on a particular table or view in a database.
The trigger is mostly used for keeping the integrity
of the information on the database.
18. Let us take the example of a trigger say an update
trigger for the employee table. Now the logic here
is let's say when a row is modified (for eg.
Emp_name is being changed) that information
needs to be emailed to a person. We can use
triggers to do this. By setting a trigger on an action
we indirectly ensure that whenever that action
takes place the corresponding trigger will fire and
the commands in the trigger will get executed.
Triggers improve performance in database