Part3 : Database Testing | How To Test Schema of Database Table | Test Cases

SDET- QA
13 Oct 202130:25

Summary

TLDRThis video tutorial guides viewers through schema testing of database tables, a fundamental aspect of ensuring data integrity. It emphasizes the importance of understanding database design documents to identify table names, columns, data types, and constraints. The presenter shares a document outlining the 'classic models' database schema and demonstrates how to create test cases for verifying table presence, naming conventions, column counts, names, data types, sizes, nullability, and keys. Using MySQL as an example, the video shows how to execute SQL queries to validate these aspects, highlighting the process of structural testing for database schema validation.

Takeaways

  • šŸ“š The video discusses the process of schema testing on database tables, emphasizing the importance of understanding table structure, column details, and data types.
  • šŸ” Before testing, one must refer to a database design document for table names, column names, data types, and sizes to ensure the requirements are well understood.
  • šŸ“ˆ The video uses a 'classic models' database as an example to demonstrate how to set up and test a MySQL database schema.
  • šŸ“ A database schema document is essential as it provides detailed information about tables, their relationships, and columns, which is crucial for creating test cases.
  • šŸ”‘ The script mentions various database objects like tables, columns, keys, and constraints, and how to verify their presence and properties through testing.
  • šŸ› ļø The video outlines specific test cases for checking table presence, naming conventions, number of columns, column names, data types, column sizes, nullability, and keys.
  • šŸ“‹ An Excel sheet is used to organize test cases, including test case IDs, descriptions, expected results, and status updates after execution.
  • šŸ’» The execution of test cases involves connecting to the database and running SQL queries to verify the schema against the expected requirements.
  • šŸ”¬ The 'information_schema.columns' table in MySQL is highlighted as a key resource for extracting metadata about table columns for testing purposes.
  • šŸ“‰ The video provides step-by-step instructions on how to execute SQL queries to test for table existence, column names, data types, column sizes, nullability, and keys.
  • šŸ”„ The process of schema testing is iterative, requiring the same tests to be performed on all tables within a database to ensure accuracy and consistency.

Q & A

  • What is the purpose of schema testing in database testing?

    -Schema testing is performed to verify the structure and integrity of the database. It ensures that the tables, columns, data types, sizes, and constraints are defined as per the database design document, which is crucial for maintaining data consistency and accuracy.

  • What are the prerequisites before starting schema testing on a database table?

    -Before starting schema testing, one must know the table name, the different columns available, the data type of the columns, and the size of the columns. These details are usually available in the database design document, which serves as a reference for testing.

  • Can you explain the role of a database design document in schema testing?

    -A database design document provides detailed information about the database schema, including the tables, their relationships, columns, data types, and sizes. It is essential for schema testing as it outlines the expected structure and constraints of the database, which testers use to create and execute test cases.

  • What does the term 'information schema' refer to in the context of databases?

    -The 'information schema' is a collection of read-only views in a database that contain metadata about all the database's tables, columns, data types, and keys. It is used to retrieve information about the database structure and is often queried during schema testing to verify the actual database structure against the expected one.

  • How can you check if a specific table exists in a MySQL database?

    -In MySQL, you can check if a specific table exists by using the 'SHOW TABLES' command followed by the table name. This command lists all the tables in the database, and you can verify the presence of the required table in the output.

  • What is the significance of checking table name conventions during schema testing?

    -Checking table name conventions ensures that the table names adhere to the naming standards specified in the design document. This is important for maintaining consistency, readability, and avoiding errors due to improper naming, such as using spaces or special characters.

  • How do you verify the number of columns in a table as per the database design document?

    -You can verify the number of columns in a table by querying the 'information schema.columns' view in MySQL. The query 'SELECT COUNT(*) FROM information_schema.columns WHERE table_name = 'your_table_name'' will return the total number of columns in the specified table, which can then be compared with the expected number from the design document.

  • What is the importance of testing column names, data types, and sizes in a table?

    -Testing column names, data types, and sizes is crucial for ensuring that the table structure matches the design document. It verifies that each column is correctly named, has the appropriate data type to store the intended data, and has the correct size to accommodate the data within the specified limits.

  • Can you explain the process of checking nullability and keys associated with table columns during schema testing?

    -During schema testing, you check nullability by verifying which columns allow NULL values, indicating that they can store unknown or missing data. You also check the keys associated with columns, such as primary keys, foreign keys, or unique keys, to ensure they enforce the necessary constraints and relationships as defined in the design document.

  • How do you structure a test case document for schema testing of database tables?

    -A test case document for schema testing should include columns like Test Case ID, Description, Expected Result, Actual Result, Test Data, and Status. It should cover various test scenarios, such as checking table presence, table name conventions, column names, data types, column sizes, nullability, and keys associated with columns.

  • What is the difference between structural testing and other types of database testing?

    -Structural testing, also known as schema testing, focuses on the physical structure of the database, such as tables, columns, and constraints. It is different from other types of testing, such as functional testing, which verifies the functionality of the database against business requirements, or performance testing, which evaluates the database's performance under load.

Outlines

00:00

šŸ“˜ Introduction to Schema Testing on Database Tables

The speaker begins by introducing the concept of schema testing on database tables, emphasizing the importance of understanding database requirements such as table names, column details, data types, and sizes. A reference to a database design document is made, which is essential for conducting tests on database objects. The 'classic models' database is mentioned as the subject of testing, with a schema document outlining tables, their purposes, relationships, and column specifications being shared. The document serves as a guide for creating test cases to verify table presence, naming conventions, column count, names, data types, sizes, and constraints.

05:05

šŸ“‹ Test Case Preparation for Database Tables

This paragraph delves into the specifics of preparing test cases for database tables. It discusses the need to verify table presence in the database schema, adherence to naming conventions, the correct number of columns, column names, data types, column sizes, nullability, and keys or constraints applied to columns. An example of an Excel sheet containing sample test cases is shared, with test case IDs and descriptions for checking various aspects of the database tables. The paragraph also explains how to execute SQL queries to check for table existence and naming conventions using the 'SHOW TABLES' command in MySQL.

10:09

šŸ” Executing SQL Queries for Schema Validation

The speaker provides a detailed walkthrough of executing SQL queries to validate the schema of a database. This includes checking the number of columns in a table using the 'COUNT' function on the 'information_schema.columns' table, verifying column names and data types, and ensuring column sizes match the design document. The paragraph explains how to use the 'DESCRIBE' command to get metadata about a table and how to use the 'information_schema.columns' table to extract detailed information about columns, including whether nulls are allowed and the type of keys associated with each column.

15:12

šŸ—‚ļø Describing the 'information_schema.columns' Table

This section describes the 'information_schema.columns' table, which contains metadata about all the tables in a MySQL database. The 'DESCRIBE' command is used to display all the fields and their information, such as data types, nullability, keys, and other details. The paragraph explains how this administrator table can be used to extract information from any table in the database, which is crucial for schema validation and testing.

20:12

šŸ–‹ļø Validating Column Names and Data Types

The speaker demonstrates how to validate column names and data types in a table using SQL queries. By selecting specific columns from the 'information_schema.columns' table, the speaker shows how to retrieve and compare column names and data types against the expected values from the database design document. The importance of matching these elements to ensure the database schema is correctly implemented is highlighted.

25:19

šŸ”‘ Checking Column Sizes and Nullability

This paragraph focuses on verifying the size of columns and their nullability as per the database design document. The speaker explains how to execute queries to retrieve column names along with their data types and sizes, and how to compare these with the expected values. The concept of null fields as unknown values is introduced, and the speaker shows how to check which columns allow nulls using the 'information_schema.columns' table.

šŸ—ļø Verifying Column Keys and Constraints

The final paragraph discusses the verification of column keys and constraints in a table. The speaker explains how to use the 'information_schema.columns' table to extract column names along with their associated keys, such as primary keys or foreign keys. The importance of understanding different types of integrity constraints in databases is mentioned, and the speaker demonstrates how to execute queries to ensure that the correct keys are associated with the columns as per the design document.

Mindmap

Keywords

šŸ’”Schema Testing

Schema testing is a type of database testing that focuses on verifying the structure and integrity of the database schema. It ensures that the database design adheres to the specified requirements. In the video, schema testing is the main theme, where the presenter discusses how to perform testing on the database schema, specifically on tables, to confirm that they meet the design document's specifications.

šŸ’”Database Element

A database element refers to a fundamental component within a database system, such as tables, columns, or keys. The script emphasizes the importance of understanding database elements like tables, which are where actual data is stored in rows and columns. The video's focus on table schema testing highlights the significance of these elements in maintaining database integrity.

šŸ’”Table

A table in a database is a structured collection of data held in rows and columns. It is a basic unit for organizing data. The script describes how to test various aspects of a table, including its existence, naming conventions, column count, and data types, which are all crucial for ensuring the table's compliance with the database schema requirements.

šŸ’”Column

A column in a database table represents a vertical entity that holds data of a specific data type. The script mentions the need to verify the number of columns, their names, data types, and sizes, which are essential for validating the table's schema. The column's attributes are tested to ensure they match the database design document.

šŸ’”Data Type

Data type refers to a classification that tells what kind of data can be stored in a column. The script discusses checking the data type of each column to ensure it aligns with the database schema. For instance, a column may be of type 'int' for integers or 'varchar' for variable-length character strings.

šŸ’”Size

In the context of a database column, size refers to the maximum amount of data that the column can hold. The script mentions verifying the size of columns to ensure they can accommodate the expected volume of data. For example, a 'varchar(50)' column can store strings up to 50 characters long.

šŸ’”Nulls

Nulls represent the absence of a value in a database column. The script explains the importance of checking whether columns accept null values or not, as this affects the data integrity and completeness. It is part of the schema testing process to confirm that nullability constraints are correctly implemented.

šŸ’”Keys

Keys in a database are used to enforce constraints on the data, such as uniqueness and referential integrity. The script discusses checking the types of keys applied to columns, such as primary keys, foreign keys, and check constraints, to ensure they are correctly associated with the columns as per the schema design.

šŸ’”Test Cases

Test cases are defined procedures or scenarios used to determine whether a particular software feature performs as intended. The script outlines creating test cases for database tables to verify their presence, naming conventions, column details, and constraints. These test cases are essential for systematic schema validation.

šŸ’”Information Schema

The information schema is a meta-database in MySQL that contains tables describing the database's structure. The script refers to the 'information schema.columns' table, which stores metadata about all the columns in all the databases. It is used to extract information necessary for schema testing, such as column names, data types, and keys.

šŸ’”Administrator Tables

Administrator tables, also known as system tables, store metadata about the database itself. The script mentions using administrator tables like 'information schema.columns' to retrieve metadata about other tables in the database, which is crucial for schema testing and ensuring the database's structural integrity.

šŸ’”MySQL

MySQL is an open-source relational database management system. The script uses MySQL as an example to demonstrate how to perform schema testing. Specific MySQL commands like 'SHOW TABLES' and 'DESCRIBE' are used to retrieve information about the database schema for testing purposes.

Highlights

Introduction to schema testing on tables, emphasizing the importance of understanding database requirements such as table names, columns, data types, and sizes.

The necessity of referencing a database design document before conducting schema testing.

Demonstration of a database schema document for 'classic models' database, detailing tables, their purposes, and relationships.

Explanation of metadata in the 'information schema.columns' table in MySQL, which stores details about database columns.

Description of test cases for verifying table presence, naming conventions, column count, and names against the schema document.

Use of SQL queries to check the number of columns in a table and compare it with the schema document.

Verification process for column names and data types using the 'information schema.columns' table in MySQL.

Importance of checking column sizes to ensure they match the schema requirements.

Testing for null fields in tables to verify if they allow null values as per the schema design.

Verification of keys and constraints associated with table columns, such as primary keys and foreign keys.

Execution of test cases through direct database connection and running SQL queries to validate table structures.

Use of an Excel sheet to organize and document test cases, including ID, description, expected results, and actual results.

Emphasis on repeating test cases for all tables in a database to ensure comprehensive schema validation.

Explanation of 'describe' command in MySQL to display metadata of a table, including fields, types, nulls, and keys.

Guidance on updating test case status to 'passed' or 'failed' based on the execution results.

Highlighting the importance of structural testing, also known as white box testing, for direct inspection of database components.

Outlook on future videos covering testing of other database objects like stored procedures and functions.

Transcripts

play00:02

hi everyone welcome you all in the today's videoĀ  we are going to see how we can perform schemaĀ Ā 

play00:07

testing on table so table is a basic databaseĀ  element in which the actual data will be storedĀ Ā 

play00:14

in multiple columns in the rows format so beforeĀ  going to test the table of the schema of the tableĀ Ā 

play00:20

so first we need to know the requirement likeĀ  what is the table name and what are the differentĀ Ā 

play00:25

columns are available and what is the data typeĀ  of the columns and the size of the column soĀ Ā 

play00:29

these details are most of the times available inĀ  database design document so that is a referenceĀ Ā 

play00:34

document we need to have before conducting testingĀ  on the database objects now let me share a smallĀ Ā 

play00:41

document here and which is basically describingĀ  the database schema of classic models databaseĀ Ā 

play00:46

so in the previous video i have shown you how toĀ  set up classic models database in mysql serverĀ Ā 

play00:52

mysql so on the same database we are going toĀ  continue the testing so this is a database schemaĀ Ā 

play00:58

document and basically which contains uh whatĀ  are the tables are available in the databaseĀ Ā 

play01:02

and what's the main purpose of the table uhĀ  including the description which is clearly givenĀ Ā 

play01:08

and this document is basically data model andĀ  which is described in detail like what are theĀ Ā 

play01:13

different tables are available and what areĀ  the relationship between the tables and whatĀ Ā 

play01:17

are the different columns are available so allĀ  this information we can get it from the smallĀ Ā 

play01:21

documentation this is basically data databaseĀ  schema and this is basically database modelĀ Ā 

play01:28

and if i just come down here so this is the actualĀ  requirement which we need uh to test the tables soĀ Ā 

play01:34

here in this database basically we have differentĀ  tables like customers products product lines andĀ Ā 

play01:39

orders and order details payments and employeesĀ  offices and so on so these are the differentĀ Ā 

play01:45

tables which are available in the database nowĀ  in this table again they have given some list ofĀ Ā 

play01:50

columns and each column is having some data typeĀ  along with the size like how much data this k thisĀ Ā 

play01:58

column can hold so that is basically representingĀ  by the size and nulls are accepting or not soĀ Ā 

play02:04

which is giving another column and the last columnĀ  is representing the keys like on which columnĀ Ā 

play02:10

what type of key is applied like primaryĀ  key or foreign key or check constraint orĀ Ā 

play02:14

multi key and so on so these are the differentĀ  keys which will be there on this particularĀ Ā 

play02:19

column so this is basically a reference documentĀ  and before conducting testing on the database andĀ Ā 

play02:25

similarly if i just look at each and every tableĀ  is having different type of columns and data typeĀ Ā 

play02:30

along with the size and so on okay this is a smallĀ  reference document and which contains all theĀ Ā 

play02:37

table information in detail so includingĀ  columns data types and everything so basedĀ Ā 

play02:42

on this document we need to prepare our test casesĀ  okay so based on this document we need to prepareĀ Ā 

play02:47

our test cases and currently this document isĀ  having only the table information but whichĀ Ā 

play02:52

also includes a lot of other information relatedĀ  to other objects so currently this document isĀ Ā 

play02:56

having only the table information what are theĀ  tables are available and what is their requirementĀ Ā 

play03:02

so by referring this document uh we have toĀ  create a test cases to test the tables okayĀ Ā 

play03:09

so what are the exact scenarios we can test on theĀ  table so let me share a small list of test casesĀ Ā 

play03:16

and what are the things we need toĀ  test on the table database tableĀ Ā 

play03:19

so first of all we need to check the tableĀ  presents on the database schema so whicheverĀ Ā 

play03:23

database we are referring like classic modelsĀ  in which the database is present or not thatĀ Ā 

play03:27

we need to check first and then we need to checkĀ  the table name conventions so whenever you createĀ Ā 

play03:33

some table name so we need to follow certainĀ  naming conventions and whether it is followingĀ Ā 

play03:37

proper naming convention or not according toĀ  the requirement document and then you need toĀ Ā 

play03:42

check the number of columns in a table like howĀ  many number of columns are there in the tableĀ Ā 

play03:46

as per the document we need to verify and checkĀ  number of uh check column names in a table so whatĀ Ā 

play03:52

are all columns are available so we need to verifyĀ  each and every column name which is properly givenĀ Ā 

play03:57

or not which is meaningful or not we need toĀ  check and then we need to check the data typeĀ Ā 

play04:02

of columns in each table so in table let us say weĀ  have a number of columns and each column is havingĀ Ā 

play04:07

some data type so what kind of data type they haveĀ  given to that particular column we have to checkĀ Ā 

play04:12

as per the design document and not only theĀ  data type we need to also check the sizeĀ Ā 

play04:18

okay so that size is also most importantĀ  so check the size of the columns in a tableĀ Ā 

play04:23

and we need to also verify check nulls fields inĀ  the table so suppose there are certain columnsĀ Ā 

play04:27

which will allow the null value sometimesĀ  such which will not allow the null valueĀ Ā 

play04:31

so we need to also check those columns whateverĀ  available and finally we need to also check theĀ Ā 

play04:37

keys that means what are the different constraintsĀ  are applied on those particular columnsĀ Ā 

play04:43

so check we need to check the column keys in aĀ  particular table so these are the different uhĀ Ā 

play04:48

tests which we need to do on the table level soĀ  we need to prepare a proper format of document uhĀ Ā 

play04:54

the particular test case document likeĀ  which is having all the different columnsĀ Ā 

play04:59

like test case id description expected actual testĀ  data and so on so based on this information weĀ Ā 

play05:05

need to first create a test cases so let me justĀ  share a small document here so now if i just lookĀ Ā 

play05:10

at this this is a small document which is createdĀ  this excel sheet basically which contains theĀ Ā 

play05:15

all the test cases sample test casesĀ  now here i have just covered only tableĀ Ā 

play05:20

and columns related test cases so what we need toĀ  verify the table and columns specific to tablesĀ Ā 

play05:25

and columns and a different type of object weĀ  will see in the upcoming series so in this videoĀ Ā 

play05:30

especially let us mainly focus on the table andĀ  fields fields are nothing but a columns now hereĀ Ā 

play05:36

you can see a test case ids and uh here you canĀ  see check table presence in a database schemaĀ Ā 

play05:42

so here how we can check how we can how we willĀ  know the database uh particular table is availableĀ Ā 

play05:47

in the database scheme or not so first we need toĀ  connect to the database and then we can execute aĀ Ā 

play05:52

query called show tables okay so in every databaseĀ  these commands will be different slightly differĀ Ā 

play05:58

so we need to fetch those commands we need toĀ  search for those commands particular databases andĀ Ā 

play06:02

here i'm following the mysql database especiallyĀ  okay so shows tables so this particular commandĀ Ā 

play06:10

will show you all the list of tables which areĀ  available in the particular database schemaĀ Ā 

play06:15

and then what we need to verify that we need toĀ  check the table name is properly given or not soĀ Ā 

play06:20

table name should be displayed in the list thatĀ  means what the table is existed on the databaseĀ Ā 

play06:26

and the same thing we are expecting here andĀ  once you it is passed then we can update theĀ Ā 

play06:30

status here and test data is not required iĀ  just given some priority to the test casesĀ Ā 

play06:34

and we can update the status passedĀ  or failed at the time of executionĀ Ā 

play06:39

now check the table name convention so in theĀ  first test we are just verifying the tableĀ Ā 

play06:43

existence or table is available or not in theĀ  database schema and the second test we are justĀ Ā 

play06:47

checking the table name convention so wheneverĀ  you give some name to the table it should be moreĀ Ā 

play06:52

meaningful according to the design document weĀ  need to check the name is given properly or notĀ Ā 

play06:56

it should not be have only one single characterĀ  or single letter double letters and like we shouldĀ Ā 

play07:02

not have any space special characters so theseĀ  things we need to verify when you're checking theĀ Ā 

play07:07

table name convention so for that also we canĀ  execute this command show tables as a queryĀ Ā 

play07:12

and this will give you all the tables list ofĀ  tables and we can check each and every tableĀ Ā 

play07:17

name is properly given or not as per the decentĀ  argument the table name should be a single wordĀ Ā 

play07:22

and table name should not contains any spaces soĀ  based on the requirement we can add a more numberĀ Ā 

play07:28

of expectations here and this is one test so tableĀ  existence we have verified and then table nameĀ Ā 

play07:35

name naming convention and the next one isĀ  check number of columns in a table so as soon asĀ Ā 

play07:41

the table is available we need to check how manyĀ  number of columns are there in the table as perĀ Ā 

play07:45

the document so for that we need to execute oneĀ  query from my sql so in the my sequel there is aĀ Ā 

play07:52

table admin table which is available thatĀ  is information underscore schema.column soĀ Ā 

play07:57

columns is actual table name and which isĀ  available in information underscore schemaĀ Ā 

play08:01

a database so this is having the metadata so whatĀ  is that metadata means the metadata is nothingĀ Ā 

play08:07

but a data about the data that means supposeĀ  i have a table in the table i have a columnĀ Ā 

play08:13

but in that that column information i want to knowĀ  like what is that name of the column what is theĀ Ā 

play08:17

size of the column what is the data type of theĀ  column so that information will be maintainingĀ Ā 

play08:22

some other tables they are basically comes underĀ  administrator tables so information schema dotĀ Ā 

play08:27

columns is administrator table in mysql databaseĀ  and similarly every database different databasesĀ Ā 

play08:34

having different type of administrator tablesĀ  and you can find all the metadata in those tablesĀ Ā 

play08:39

so if i execute this particular query select countĀ  star as a number of columns this alias base scaleĀ Ā 

play08:45

i'm giving from information underscore schemaĀ  dot columns where table name equal to customer soĀ Ā 

play08:51

whichever table you want to find or on whicheverĀ  table you want to find the number of columns youĀ Ā 

play08:55

can specify the table name here and that willĀ  give you number of columns which are present inĀ Ā 

play09:00

this particular table so this is a query whichĀ  you have to execute on mysql and then this willĀ Ā 

play09:06

return the value how many total number of columnsĀ  are available in the database so this is one testĀ Ā 

play09:12

and now the next one is check column namesĀ  in the table so here what are the columnsĀ Ā 

play09:16

are available and what are the names are givenĀ  properly or not as per the documentation we needĀ Ā 

play09:21

to go through so here in the documentation theyĀ  clearly provided what are the column names andĀ Ā 

play09:25

what are the data type and size so everything isĀ  clearly mentioned so accordingly we need to checkĀ Ā 

play09:31

so check column names in the table so for thatĀ  what we can do is we can also execute this commandĀ Ā 

play09:36

or sql query select the column name so as iĀ  said information underscore schema.columnsĀ Ā 

play09:41

is administrator table so which contains allĀ  the metadata information so from that we canĀ Ā 

play09:46

extract this column data so column underscoreĀ  name from information underscore schema.columnsĀ Ā 

play09:51

where we need to specify the table name so thisĀ  particular query will return the number of columnsĀ Ā 

play09:58

all the columns names from the table what are allĀ  columns are available from the table it will showĀ Ā 

play10:02

you just the column names from the table andĀ  then we need to check those column names areĀ Ā 

play10:08

available as mentioned in the database documentĀ  again so here whatever column names they haveĀ Ā 

play10:13

exactly mentioned the names are exactly same orĀ  not we need to verify and the next test case isĀ Ā 

play10:18

check the data type of column so in the previousĀ  test case we just verify the names of the columnsĀ Ā 

play10:23

now in this we need to verify the data type ofĀ  the columns and for that we need to access anotherĀ Ā 

play10:28

column from the same table like informationĀ  schema dot columns is having one more columnĀ Ā 

play10:33

called column underscore name data underscore typeĀ  so column name along with the data type i am ableĀ Ā 

play10:38

to access so these two things i am just trying toĀ  retrieve from the information schema dot columnsĀ Ā 

play10:44

table where table name equal to customers so thisĀ  query will give you exactly what are the columnsĀ Ā 

play10:50

are available in the table and what are the dataĀ  types of those particular columns so once you getĀ Ā 

play10:56

the data from this query so then we need to checkĀ  that data along according to our documentationĀ Ā 

play11:02

and that is one test and the next test caseĀ  check the size of the columns so there are threeĀ Ā 

play11:08

different cases the first case we just verifyĀ  the names of the columns in the fifth test caseĀ Ā 

play11:13

we just verify the data type of the column nowĀ  here we are checking the size of the column okayĀ Ā 

play11:18

suppose when i say var card and which having someĀ  size like 10 15 or 20 something so we need to alsoĀ Ā 

play11:25

verify the size of each and every column in theĀ  table or each and every field in a table so againĀ Ā 

play11:30

we use the same admin table information underscoreĀ  schema dot columns where table name equal toĀ Ā 

play11:35

customer and this will give you column name i'mĀ  printing column name along with the column typeĀ Ā 

play11:41

okay so you need to remember few number of columnsĀ  here we are using a column name okay so this is aĀ Ā 

play11:48

column name and here we are using column nameĀ  along with the data type both we are testingĀ Ā 

play11:54

and here we are checking column name and columnĀ  type also column type in the sense what againĀ Ā 

play12:00

what type of column it is again data type columnĀ  name and data type will be displayed that meansĀ Ā 

play12:06

the size of the column will be displayed and hereĀ  null's fields in the table so there is anotherĀ Ā 

play12:11

requirement here so if i just look at this columnĀ  so nulls are allowed or not no means not allowedĀ Ā 

play12:16

yes means allowed so we need to check thisĀ  information also again for that also we have aĀ Ā 

play12:22

another column called e is nullable and thisĀ  column is available in information schema.columnĀ Ā 

play12:27

so we need to capture these two column name alongĀ  with the is null so this will say no or yes andĀ Ā 

play12:34

once you return the data no aureus then we need toĀ  compare with our expected data and then we need toĀ Ā 

play12:39

make or pass or fail from the sameĀ  table we need to access all the dataĀ Ā 

play12:45

and the next one check column keys in aĀ  table so each and every column is sometimesĀ Ā 

play12:49

having some primary equal key or foreign key orĀ  check constraint or whatever it is so we needĀ Ā 

play12:54

to verify those keys are associated with thoseĀ  columns or not and that keys information alsoĀ Ā 

play12:59

we can extract from the same table informationĀ  underscore schema.columns so this is a table nameĀ Ā 

play13:04

and and we need to extract uh two columnsĀ  again column name and column key these areĀ Ā 

play13:10

the two things we are going to extract from theĀ  same table and whatever the data we are gettingĀ Ā 

play13:15

from this query we we are again comparing withĀ  our expected data as per the design so these areĀ Ā 

play13:21

the few test cases which we can write on the tableĀ  and fields fields or mathematic columns in a tableĀ Ā 

play13:28

and this is basically schema validation structuralĀ  testing internally we are testing the table levelĀ Ā 

play13:35

columns and fields and everything so that isĀ  a basically uh schema testing we are basicallyĀ Ā 

play13:41

focusing mainly on the table schema testing so howĀ  we can execute these queries so now let us see theĀ Ā 

play13:46

execution part so this is the design part once youĀ  understand this document and we need to understandĀ Ā 

play13:51

all the tables what are all tables are availableĀ  and what are the relationships and uh then we needĀ Ā 

play13:57

to analyze this data model what are the columnsĀ  data type size and available so finally we need toĀ Ā 

play14:02

based on this document we need to create a smallĀ  excel sheet like this and test cases document andĀ Ā 

play14:07

now we need to execute these test cases directlyĀ  by connecting the database so now let me connectĀ Ā 

play14:13

to the database so here i already connected to myĀ  mysql database and i already have a classic modelsĀ Ā 

play14:18

database which is already set up in previous videoĀ  now if you expand this there are multiple tablesĀ Ā 

play14:24

are there so here whatever test cases we haveĀ  written here these test cases we need to repeatĀ Ā 

play14:28

for all the tables and currently here i am takingĀ  only one table that is a customers table and youĀ Ā 

play14:34

need to repeat the same test cases and you needĀ  to repeat the same test cases for multiple tablesĀ Ā 

play14:39

whatever tables are available in your databaseĀ  for all the tables you need to perform the testingĀ Ā 

play14:45

right but here you need to just change the tableĀ  name here i have used customers table for everyĀ Ā 

play14:49

test so instead of customers we need to specifyĀ  the other tables of the other names of the tablesĀ Ā 

play14:56

now let us see the execution part so let us seeĀ  each and every query how it is going to executeĀ Ā 

play15:01

now i told you one important uh table name rightĀ  especially in my sequel that is informationĀ Ā 

play15:06

underscore schema.columns and if i just look atĀ  this table and what are the content is availableĀ Ā 

play15:11

in the table go to my sql and go to the sqlĀ  query open this equal query and here just typeĀ Ā 

play15:19

describe and information schema.columns now let usĀ  execute this query and see what it is uh giving soĀ Ā 

play15:27

now we can just see this is the administratorĀ  table and which contains all metadata forĀ Ā 

play15:32

regarding all the tables you can just look at thisĀ  this is also a table which is available in theĀ Ā 

play15:38

information schema this is basically administratorĀ  database inside this uh when you execute this whenĀ Ā 

play15:43

i describe this particular table and what is theĀ  describe command will do the describe commandĀ Ā 

play15:48

will display all the information metadata ofĀ  the table like all the fields information whatĀ Ā 

play15:53

are the type and what is the null keys and otherĀ  information will be displayed in this so now byĀ Ā 

play15:59

using this table by taking help of this table weĀ  will extract the information from any table it canĀ Ā 

play16:05

be any table we can extract the information likeĀ  table catalog table schema table name column nameĀ Ā 

play16:11

ordinal position like keys nullable data type soĀ  there are so many like say column key column typesĀ Ā 

play16:18

collation name so these are different informationĀ  will be stored in this administrator tableĀ Ā 

play16:23

so by taking help of this table we can getĀ  any data or any information of the tableĀ Ā 

play16:28

which is available in our database now by takingĀ  help of this particular table let's run theĀ Ā 

play16:34

particular code so first of all we need to connectĀ  to the classic borders classic models database soĀ Ā 

play16:39

for that i'm using use command use classic modelsĀ  so in my sequel what this command will do thisĀ Ā 

play16:46

command basically focus only on the myc classicĀ  model because there are other databases also thereĀ Ā 

play16:52

so this command will say like on which databaseĀ  we are going to execute your query so now it isĀ Ā 

play16:57

connected to the classic models database now it isĀ  using classic model database and once you connectĀ Ā 

play17:03

it then we need to execute this query so firstĀ  of all let's see our table is there or not showĀ Ā 

play17:09

tables is my command let me just execute showĀ  tables [Music] so this particular command willĀ Ā 

play17:17

give you what are all tables are available in theĀ  classic models database schema now let me executeĀ Ā 

play17:22

now you can see the customer is available as aĀ  first table and totally a tables are there soĀ Ā 

play17:27

customer employees offices order details ordersĀ  payments products product lines and products soĀ Ā 

play17:34

these are the tables which are available in theĀ  database so customers table is already availableĀ Ā 

play17:38

by database so with this uh this particular testĀ  is got passed you can see okay as per expectation

play17:49

so actual result is what so table isĀ  present we can say as per uh expectation

play17:57

okay so now this is got passed let me update as aĀ  past now the next one check table name conventionĀ Ā 

play18:04

so what we are expecting here table name shouldĀ  be a single word table so table name should notĀ Ā 

play18:09

contains any spaces and uh this is applicableĀ  for all the tables if i just look at all theĀ Ā 

play18:15

table names there are single word tablesĀ  are there there is no spaces or there isĀ Ā 

play18:19

no special characters nothing so everythingĀ  is fine so i can also make this test pass

play18:27

right so now the next one check the numberĀ  of columns in a table how we can verifyĀ Ā 

play18:30

the number of columns in a table so we canĀ  just execute this command let me show youĀ Ā 

play18:36

so what is this command will say select accountĀ  star as so this is basically alias because if evenĀ Ā 

play18:43

if you don't specify this the value will come hereĀ  but if you want to give some proper column name soĀ Ā 

play18:48

i can just specify this is alias so count star asĀ  a number of columns from and whatever the metadataĀ Ā 

play18:55

we want to get from the for the particular tableĀ  we will able to access from information schemaĀ Ā 

play19:01

so select the count star as a number of columnsĀ  from information scheme underscore schema.columnsĀ Ā 

play19:06

and where we need to specify the table nameĀ  for which table you want to get informationĀ Ā 

play19:11

so we need to get the table name customers soĀ  when you execute this particular executable ofĀ Ā 

play19:17

this particular statement this will give exactlyĀ  how many number of columns are available insideĀ Ā 

play19:21

this particular table okay so select count star asĀ  number of columns so this is number of columns heĀ Ā 

play19:28

says just a name column alias we can say and evenĀ  if you're not specifying no problem it will justĀ Ā 

play19:34

print the value like this let me executeĀ Ā 

play19:39

so it will give you just like count star so justĀ  if you want to give some proper alias you can sayĀ Ā 

play19:43

as number of columns and then you can executeĀ  this query so once you executed this query so thisĀ Ā 

play19:50

will give you total number of columns which areĀ  available in the table and then we need to compareĀ Ā 

play19:54

with our expected so expected is also 13 actual isĀ  also 13 so then i can make my test method passedĀ Ā 

play20:02

this is one test and next one is check columnĀ  names in the table so each column name isĀ Ā 

play20:07

properly given or not as per the design documentĀ  we need to check so for that we need to extractĀ Ā 

play20:12

only column names so here instead of count starĀ  we need to just specify the column next let'sĀ Ā 

play20:18

say select the column name this particular columnĀ  name is already available in this particular tableĀ Ā 

play20:23

information schema.columnstable this is againĀ  admin statement administration table all metadataĀ Ā 

play20:29

will be maintained in this so here we need toĀ  specify the table name so select a column nameĀ Ā 

play20:35

and what this command will do this commandĀ  will extract column names only column namesĀ Ā 

play20:40

from this particular table now let's execute thisĀ  command and it will show you only column namesĀ Ā 

play20:46

from this table you can see customer numberĀ  customer name contact last name contact firstĀ Ā 

play20:51

name phone address line one address line twosĀ  only columns you are verifying just the columnĀ Ā 

play20:56

names here we are not verifying size or date typeĀ  or nothing we are just verifying only the columnĀ Ā 

play21:00

names here so we can just look at here these areĀ  the different columns it is displayed then we needĀ Ā 

play21:05

to compare these column names manually with ourĀ  uh document so for the customer document what areĀ Ā 

play21:12

the column names they have given so these areĀ  exactly column names which are matching withĀ Ā 

play21:16

the column names which are alreadyĀ  available in the table so that we need toĀ Ā 

play21:20

compare and match and if everything is equalĀ  then we can make this as a past so like this weĀ Ā 

play21:26

can execute this query and we can get only columnĀ  name from the table and then if you want to testĀ Ā 

play21:31

the same thing for another table just changeĀ  the table name here and that will give you theĀ Ā 

play21:35

number of columns in another table okay so thisĀ  is a query which we need to execute to displayĀ Ā 

play21:41

only column names and then we can compare withĀ  the as per the documentation and then we can makeĀ Ā 

play21:45

it is passed or failed so now the same columnsĀ  are available so i'm just making this as a pastĀ Ā 

play21:52

and now let's go to the next one check the dataĀ  type of the columns in a table so previous test weĀ Ā 

play21:57

have just verified only column names are availableĀ  or not the names are correctly given or not but inĀ Ā 

play22:03

this time we have to check the data type of theĀ  column so what kind of data type they have givenĀ Ā 

play22:07

in each and every column so for that we need toĀ  execute the same query but we need to extractĀ Ā 

play22:13

other column let me show you this so selectĀ  column name so i'm extracting column name alongĀ Ā 

play22:20

with the data type so data type is also one of theĀ  column which is available in this particular tableĀ Ā 

play22:25

so column name along with the data typeĀ  i want to get from this table whereĀ Ā 

play22:29

table name equal to customers so now whenĀ  i execute this query so this will give youĀ Ā 

play22:34

the column names along with the data typeĀ  so previously we extracted only column namesĀ Ā 

play22:40

but this time we are extracting column namesĀ  along with the data type and again here we are notĀ Ā 

play22:45

extracting the size we are just extracting onlyĀ  the data so according to this we need to againĀ Ā 

play22:51

check this data which is correct or not accordingĀ  to our documentation so the same data typeĀ Ā 

play22:57

values are getting or not for a particular columnĀ  wise we need to verify so this particular columnĀ Ā 

play23:02

is having inter type so again we need to checkĀ  this column is having intertype then customerĀ Ā 

play23:06

name contact last name first name these are allĀ  wirecard types so these are all wirecard typesĀ Ā 

play23:12

right so like this we need to compare each andĀ  every column along with the data type and onceĀ Ā 

play23:17

everything is fine so credit limit is a decimal soĀ  here also credit decimal credit limit is a decimalĀ Ā 

play23:24

so like this we need to compare the data typeĀ  of every column so if everything is matches thenĀ Ā 

play23:30

we can make this test method test case alsoĀ  passed this is data type validation of the columnsĀ Ā 

play23:37

and next one check the size of the columns soĀ  we verified the names of the columns verifiedĀ Ā 

play23:42

the data type of the columns now we need toĀ  verify the size of the column so each and everyĀ Ā 

play23:47

column is having a sum size let us say if you wantĀ  to store the name of a person i can give 15 or 20Ā Ā 

play23:53

or 30 with worker type so that particular columnĀ  will allow you to store only the names which areĀ Ā 

play24:00

uh the digits of the character so which within aĀ  limit let's say when i say 15 i can store only 15Ā Ā 

play24:05

characters maximum right the name should havingĀ  only 15 characters so that is decided by theĀ Ā 

play24:11

size of the column so that also we need toĀ  verify so we need to execute the same query againĀ Ā 

play24:18

and here from the same administrator table thisĀ  time we have to extract the column type not theĀ Ā 

play24:25

data type we have to extract the column type soĀ  column name and column type so column type willĀ Ā 

play24:30

give you the data type along with the size nowĀ  let's execute this command and you can see hereĀ Ā 

play24:38

so these are the different column names alongĀ  with the data type and the size both have givenĀ Ā 

play24:43

so when i say customer number int is a data typeĀ  11 is a size and customer name varchar is a dataĀ Ā 

play24:49

type 50 is a size so this data exactly shouldĀ  match with our documentation so exactly matchĀ Ā 

play24:56

with our documentation okay and this thingĀ  we need to compare so here we are basicallyĀ Ā 

play25:02

comparing the we are checking the size of theĀ  column okay these three test cases we are checkingĀ Ā 

play25:08

three different things in the first one we areĀ  just checking the names of the column in thisĀ Ā 

play25:11

query we are checking the column data type andĀ  in this we are verifying the size of the columnĀ Ā 

play25:19

as per the document is is correct or not soĀ  the size of the column is perfectly fine almostĀ Ā 

play25:24

everything is 50 and first one is 11 last oneĀ  is eleven ten comma two is a decimal and if iĀ Ā 

play25:30

just look at the documentation also ten commaĀ  two decimal int is eleven and rest of them allĀ Ā 

play25:34

are fifty and postal code is a fifteen isĀ  there so you can just look at here postalĀ Ā 

play25:39

code is a fifteen perfectly fine so in thatĀ  case we can just make this test case passed

play25:47

all right so now the column level validations areĀ  done so there is there are two more validations weĀ Ā 

play25:52

need to do on the table that is check null fieldsĀ  in a table null fields how we can capture the nullĀ Ā 

play25:58

field so if i just look at the document againĀ  so here there are number of columns are thereĀ Ā 

play26:03

so each column is say no no means no meansĀ  what that particular name will not allow youĀ Ā 

play26:10

nulls yes means what it will allow you nullsĀ  or repetition of values are not allowedĀ Ā 

play26:15

so now you can see check null fields in a tableĀ  basically null is nothing but unknown valueĀ Ā 

play26:20

okay if you don't know the value you can just makeĀ  it as a null that is unknown value and later youĀ Ā 

play26:25

can update the value okay so if you want to knowĀ  what are the columns or null allowed or not so weĀ Ā 

play26:31

can execute this command and all these data weĀ  can extract from the administrator table whichĀ Ā 

play26:37

is information schema dot columns so columnĀ  name along with the e is underscore nullableĀ Ā 

play26:43

from information schema dot columnsĀ  where table name equal to customersĀ Ā 

play26:48

so when you execute this now you can getĀ  the same thing so this particular columnĀ Ā 

play26:52

no is nullable no customer name is nullableĀ  no contact last name is nullable noĀ Ā 

play27:00

okay so like this we can just verify uh theseĀ  nullable fields for every column as per theĀ Ā 

play27:06

documentation like this and similarly finally weĀ  need to verify the keys what are the differentĀ Ā 

play27:12

keys are associated with those columns and ifĀ  i just look at here for every table there isĀ Ā 

play27:17

a primary key there is a multiple key here andĀ  uh see here primary key and multiple keys areĀ Ā 

play27:23

there and some tables are having two primary keysĀ  some tables are having two multiple keys like thisĀ Ā 

play27:28

right so now we need to verify thoseĀ  keys are properly associated with theĀ Ā 

play27:32

columns or not so for that we have one moreĀ  command here column key we need to extractĀ Ā 

play27:38

so execute this command so this one check theĀ  null fields first right so let me execute thisĀ Ā 

play27:44

so this is the one we already executed thisĀ  so if i just execute this this will give youĀ Ā 

play27:50

nullable columns so this is sameĀ  thing so i can just also make it pastĀ Ā 

play27:57

and then check the column keys in a tableĀ  so in the table we can also verify thatĀ Ā 

play28:01

each and every column is associated withĀ  the constraint properly or not so forĀ Ā 

play28:04

that we can also execute this command or thisĀ  particular query from information schema only soĀ Ā 

play28:10

column name along with the column key soĀ  what is the column key representing with thisĀ Ā 

play28:15

representing a particular key is allocated forĀ  that particular column or not so understand thisĀ Ā 

play28:21

we need to know what are the different constraintsĀ  are available in the database all these things soĀ Ā 

play28:25

integrity constraints concept you have to knowĀ  uh if you understand this one okay this is aĀ Ā 

play28:31

dependent topic so column key from informationĀ  schema dot columns where table name equal toĀ Ā 

play28:36

customers so when i execute this query so thisĀ  will give you exact what are the columns areĀ Ā 

play28:41

available each column is associated with the whatĀ  is the column key here prime is a primary keyĀ Ā 

play28:47

means multiple key okay sometimes you may seeĀ  check constraints sometimes you see you needĀ Ā 

play28:52

not null constraint like this so these are theĀ  different keys you can see in this table so thisĀ Ā 

play28:57

is the query which we have to execute to know whatĀ  are all keys are available or respective columnsĀ Ā 

play29:04

okay so currently we have only in this tableĀ  i have only first one is a primary key customĀ Ā 

play29:09

customer number and sales repo saleĀ  representative employee number is a multiple keyĀ Ā 

play29:15

okay multiple means it will allow theĀ  multiple values and uh now this is a pastĀ Ā 

play29:23

so this is how we need to just verify the tableĀ  structure basically we are mainly focusing on theĀ Ā 

play29:28

structure so which is becomes under structuralĀ  testing structural testing and which is againĀ Ā 

play29:34

called as a white box testing we are checking theĀ  directly table so table columns table column dataĀ Ā 

play29:41

type and table columns uh size of the columns theĀ  data type of the columns and what are the keys areĀ Ā 

play29:47

associated with those columns and whether theseĀ  keys are those those columns are allowing nulls orĀ Ā 

play29:53

not so those things we are verifying basically onĀ  the table uh table component okay so these are theĀ Ā 

play29:59

few test cases which we can write and execute onĀ  the table level so the same test we can continueĀ Ā 

play30:06

with the rest of the tables which are availableĀ  in the database okay and uh in the next videoĀ Ā 

play30:12

i'll show you how we can test other type ofĀ  objects like stored processor functions and so onĀ Ā 

play30:18

and uh that's it so that's all for this video guysĀ  thanks for watching we'll see in the next video

Rate This
ā˜…
ā˜…
ā˜…
ā˜…
ā˜…

5.0 / 5 (0 votes)

Ƅhnliche Tags
Database TestingSchema ValidationStructural TestingWhite BoxMySQLTable StructureData TypesColumn KeysNull FieldsTest CasesClassic Models
Benƶtigen Sie eine Zusammenfassung auf Englisch?