Handouts - 02 (Data Base Intro)
Handouts - 02 (Data Base Intro)
Note: Follow Handouts & Material & Examples which are discussing in classes to get good knowledge on ETL Testing
Session-2
Topics covered in session:
1. what is Database?
2. What is a Table?
3. DDL, DML, DCL and DRL commands
4. Teradata Data dictionary
1. What is Database?
Database: Database is nothing but collection of database objects for the purpose of
storing/maintaining data.
Database Objects: In database we are having different database objects, those are
1. Tables 2.Views 3.Triggers 4.Macros 5.Stored Procedures
2. What is a table?
Table: In a table we can able to store data based on requirement and we can represent that
data in 2-D format, means we can represent data in Rows X Columns format.
Row: Instance of an entity
Columns: Characteristics of an entity and in columns we need to maintain like data
Entity: Entity is nothing but real time object for which we are collecting data.
- If you want to create a table or if you want to maintain data in that table or if you
want to maintain data in table we need to maintain communication with database.
- For the purpose of maintaining communication with database we should have to use
a language, that language we are calling as SQL.
3. Types of commands in SQL: (DDL, DML, DCL & DRL)
In SQL we are having below type of commands.
DDL: (Data Definition Language)
If you want to perform any kind of operations on structure of the table you should have
to go for DDL commands. We can perform below kind of operations on structure of the
table.
Define the structure of the table - CREATE
Change the structure of the table - ALTER
Remove the structure of the table - DROP
Whenever you want to define the structure of that table you should have to understand
below things.
1. Tablename 2.Columnname 3.Datatype 4.Datatype length 5.Constraints
In real time project all this information will be provided by Data Modeler. He will
take requirements from DA/BA and provide model of database in a document called as
Physical Data Model (PDM).
BA/DA (Requirement) -----Data Modeler--PDM Document
Whenever we have defined the structure of the table in Teradata that structure will
be stored in to Data dictionary in the form of tables. We are having two different tables in
Teradata to store structure, those are 1. Dbc.Tables 2. Dbc.columns
DBC.Tables: Whenever we have created any new table that table information will be
stored in Dbc.Tables. For example srinivas created Emp table on 2012-01-01 in to samples
database. This information will be stored automatically in to DBC.tables in below format.
DBC.columns: Whenever we are creating a table, that table column names will be stored in
to DBC.columns in below format.
Scenario 1: If you want to create a new table first we need to cross whether that table is
available or not, to do this we need to write query as below.
Select * from dbc.tables where tablename=’emp’
This query should have to give output as 0 records if you want to create new Emp table
Scenario 2: If you want to find what all are the columns available in table we have to
prepare query as below.
Select * from dbc.columns where tablename=’emp’