You are on page 1of 7

Assignment 6

Ques1) Write SQL commands to create and to populate tables


Ques2) Write SQL commands to create view of a table
Ques3) Write SQL command of Materialized View

CREATE MATERIALIZED VIEW ViewName


[REFRESH
[FAST | COMPLETE]
[NEXT SYSDATE[+NUMTODSINTERVAL(IntegerLiteral),IntervalUnit]]
AS SelectQuery
[PRIMARY KEY (ColumnName [,…])]
[UNIQUE HASH ON (HashColumnName [,…])
PAGES = PrimaryPages]

Ques4) Write difference between view and materialized view

View:

 logical representation of data to access from underlying tables.


 View has logical structure and does not occupy space.
 Changes get affected in corresponding tables.

Materialized view

 Pre calculated data persists in materialized view.


 It has physical data space occupation.
 Changes will not get affected in corresponding tables
Ques5) Implement Slowly Changing Dimension (SCD) concept for dimensional data.

Type1 correction of error

This methodology overwrites old with new data, and therefore does not track historical data. Its
common uses are for misspelled names. (Assuming you won't need to know how it was
misspelled in the past.)

Example of a supplier table:

Supplier_Key Supplier_Code Supplier_Name Supplier_State


123 ABC Acme Supply Co CA
Type 2

Preservation of history

This method tracks historical data by creating multiple records for a given natural key in the
dimensional tables with separate surrogate keys and/or different version numbers. Unlimited
history is preserved for each insert.

For example, if the supplier relocates to Illinois the version numbers will be incremented
sequentially:

Supplier_Key Supplier_Code Supplier_Name Supplier_State Version.


123 ABC Acme Supply Co CA 0
124 ABC Acme Supply Co IL 1

Type 3

Tentative soft change

his method tracks changes using separate columns and preserves limited history. The Type II
preserves unlimited history as it's limited to the number of columns designated for storing
historical data. The original table structure in Type I and Type II is the same but Type III adds
additional columns. In the following example, an additional column has been added to the to
record the supplier's original state - only the previous history is stored.

Supplier_K Supplier_C Supplier_Na Original_Supplier_ Effective_D Current_Supplier_


ey ode me State ate State
Acme Supply 22-Dec-
123 ABC CA IL
Co 2004
Insert into new column value
Ques6) Perform the experiment of Cleansing of Data to remove “-“ from a column.

You might also like