Pages

12 August 2018

UNIX - Basic UNIX commands with Examples


Below are the basic UNIX commands which are frequently used in ETL Testing and are often asked in interviews :-

1.)  ls
ls command is used for listing of files in a directory.

Example:

ls












2.) cat
cat command is used for displaying the contents in a file.

Example:












3.) cd
cd command is used for changing from one directory to another directory.

Example:







4.) touch
touch command is used for creating zero byte file or empty file.

Example:










5.) cp
cp command  is used to copy the contents of source file into target file.

Example:







6.) mv
mv command is used to move files from one directory to another directory. It is also used for renaming files

Example:










7.) rm
rm command is used to remove or delete files.

Example:









8.) mkdir
mkdir command is used to create directories for organizing files.

Example:








9.) head
head command is used to print first n number of lines from the file.  By default, it displays first 10 lines from each file.

Example:




















10.) tail
tail command is used to print last n number of lines from the file.  By default, it displays last 10 lines from each file.

Example:




















11.) wc
wc command is used to find number of lines, words and characters in a file.

Example:













12.) grep
grep command print lines in files that match patterns.

Example:








13.) pwd
pwd command prints current working directory

Example:








14.) chmod
chmod command is used to change the permission of file or directory.

Example:








15.) man
man command displays the manual page for a given command.

Example: man ls

30 January 2017

DWH - SLOWLY CHANGING DIMENSION (SCD)

When dimension changes over a period of time, it is called as Slowly Changing Dimension and it is very popularly known as SCD. It is used for tracking history of dimension attributes.There are mainly six types of SCD which are TYPE 0, TYPE 1, TYPE 2, TYPE 3, TYPE 4 and TYPE 6.

   EmployeeDeatil table mentioned below is used as an illustration, contains columns Emp_Key, EmployeeID, Name and Designation. Emp_key is a Surrogate Key.

TYPE 0 (Retains original value): This is a passive method. Value remains exactly the same as that of when inserted for the first time. This is not often used.

TYPE 1 (Overwriting old value): In this type, old value is replaced by a new value in the dimension table. Old data is lost in this process. 
           Let us assume Employee has been promoted from Test Engineer to Test Lead. So, Designation column has been replaced with new value as shown below. Thus we are not maintaining any history of changes that has taken place.

Old Value


Emp_Key
EmpID
Name
Designation
111
1001
Sunil
Test Engineer

New Value

Emp_Key
EmpID
Name
Designation
111
1001
Sunil
Test Lead


TYPE 2 (Adding  new row): In this type, a complete

4 September 2016

DWH - Data Validation Testing Using Minus Query Method

Data Validation in Data Warehouse has always been challenging. One of the most frequently way of data validation is by using MINUS/ EXCEPT operator. MINUS operator is used in ORACLE database while EXCEPT is used in SQL SERVER database. Before proceeding to testing part, first let us understand the functionality of MINUS operator.

      MINUS operator gives the differences between the two table. Suppose we have two tables. Lets consider table A and B. When we will do MINUS operation between table A and table B (ie. A - B), it will return all those records which are present in table A but not in B. Similarly when we do  MINUS operation between table B and table A (ie. B - A), it will return all those records which are present in table B but not in A.

       One point to remember while doing MINUS operation between first table and second table is that every row in first table is searched in second table and if not found , that row is returned as a result set. Similarly, while doing MINUS operation between second table and first table is that every row in second table is searched in first table and if not found , that row is returned as a result set. 

        If all the rows  present in first table is present in second table as well then output or result of first table MINUS second table will be empty result set or in other words nothing will be returned.  Similarly, if all the rows present in second table is also present first table, then output or result of second table MINUS first table will be empty result set or in other words nothing will be returned.
Let us understand the usage of MINUS operator in data validation. Below SourceTable and TargetTable is used for illustration. 


     SourceTable                                      TargetTable
ID
Name
ID
Name
1
ABC
1
ABC
2
DEF
2
DEF
3
GHI
3
GHI
4
JKL
4
JKL
5
LMN
5
LMN
6
OPQ
8
OPQ

SQL / ORACLE- Scenario Based Interview Questions & Answers PART- 11


SCENARIO:  

We have EMP_DETAILS table which contains employee details such as EMPID, GENDER,EMAILID and DEPT_ID columns. We want to display all emailid associated with a particular DEPT_ID to be concatenated with semicolon as shown below.

EMP_DETAILS Table

EMPID
GENDER
EMAILID
DEPT_ID
1111
M
YYYYY@gmaix.com
104
2222
M
ZZZ@gmaix.com
103
3333
F
AAAAA@gmaix.com
102
4444
F
PP@gmaix.com
104
5555
M
CCCC@yahu.com
101
6666
M
DDDDD@yahu.com
100
7777
F
E@yahu.com
102
8888
M
M@yahu.com
102
9999
F
SS@yahu.com
100
     

EXPECTED RESULT: