Wednesday, November 30, 2011

Difference between data mart and data warehouse


Data Mart
Data Warehouse
Data mart is usually sponsored at the department level and developed with a specific issue or subject in mind, a data mart is a data warehouse with a focused objective.
Data warehouse is a “Subject-Oriented, Integrated, Time-Variant, Nonvolatile collection of data in support of decision making”.
A data mart is used on a business division/ department level.
A data warehouse is used on an enterprise level
A Data Mart is a subset of data from a Data Warehouse. Data Marts are built for specific user groups.
A Data Warehouse is simply an integrated consolidation of data from a variety of sources that is specially designed to support strategic and tactical decision making.
By providing decision makers with only a subset of data from the Data Warehouse, Privacy, Performance and Clarity Objectives can be attained.
The main objective of Data Warehouse is to provide an integrated environment and coherent picture of the business at a point in time.

What is the difference between snow flake and star schema


Star Schema
Snow Flake Schema
The star schema is the simplest data warehouse scheme.
Snowflake schema is a more complex data warehouse model than a star schema.
In star schema each of the dimensions is represented in a single table .It should not have any hierarchies between dims.
In snow flake schema at least one hierarchy should exists between dimension tables.
It contains a fact table surrounded by dimension tables. If the dimensions are de-normalized, we say it is a star schema design.
It contains a fact table surrounded by dimension tables. If a dimension is normalized, we say it is a snow flaked design.
In star schema only one join establishes the relationship between the fact table and any one of the dimension tables.
In snow flake schema since there is relationship between the dimensions tables it has to do many joins to fetch the data.
A star schema optimizes the performance by keeping queries simple and providing fast response time. All the information about the each level is stored in one row.
Snowflake schemas normalize dimensions to eliminated redundancy. The result is more complex queries and reduced query performance.
It is called a star schema because the diagram resembles a star.
It is called a snowflake schema because the diagram resembles a snowflake.

Difference between OLTP and DWH/DS/OLAP


OLTP
DWH/DSS/OLAP
OLTP maintains only current information.
OLAP contains full history.
It is a normalized structure.
It is a de-normalized structure.
Its volatile system.
Its non-volatile system.
It cannot be used for reporting purpose.
It’s a pure reporting system.
Since it is normalized structure so here it requires multiple joins to fetch the data.
Here it does not require much joins to fetch the data.
It’s not time variant.
Its time variant.
It’s a pure relational model.
It’s a dimensional model.

Hints in oracle


  • ALL_ROWS
    One of the hints that 'invokes' the
    Cost based optimizer
    ALL_ROWS is usually used for batch processing or data warehousing systems.

(/*+ ALL_ROWS */) 

  • FIRST_ROWS
    One of the hints that 'invokes' the
    Cost based optimizer
    FIRST_ROWS is usually used for OLTP systems.

(/*+ FIRST_ROWS */) 

  • CHOOSE
    One of the hints that 'invokes' the
    Cost based optimizer
    This hint lets the server choose (between ALL_ROWS and FIRST_ROWS, based on
    statistics gathered.
  • HASH
    Hashes one table (full scan) and creates a hash index for that table. Then hashes other table and uses hash index to find corresponding records. Therefore not suitable for < or > join conditions.

/*+ use_hash */

Hints are most useful to optimize the query performance.

Differences between rowid and rownum


Rowid
Rownum
Rowid is an oracle internal id that is allocated every time a new record is inserted in a table. This ID is unique and cannot be changed by the user.
Rownum is a row number returned by a select statement.
Rowid is permanent.
Rownum is temporary.
Rowid is a globally unique identifier for a row in a database. It is created at the time the row is inserted into the table, and destroyed when it is removed from a table.
The rownum pseudocoloumn returns a number indicating the order in which oracle selects the row from a table or set of joined rows.

Differences between stored procedure and functions


Stored Procedure
Functions
Stored procedure may or may not return values.
Function should return at least one output parameter. Can return more than one parameter using OUT argument.
Stored procedure can be used to solve the business logic.
Function can be used to calculations
Stored procedure is a pre-compiled statement.
But function is not a pre-compiled statement.
Stored procedure accepts more than one argument.
Whereas function does not accept arguments.
Stored procedures are mainly used to process the tasks.
Functions are mainly used to compute values
Cannot be invoked from SQL statements. E.g. SELECT
Can be invoked form SQL statements e.g. SELECT
Can affect the state of database using commit.
Cannot affect the state of database.
Stored as a pseudo-code in database i.e. compiled form.
Parsed and compiled at runtime.