DWM Exp 2 C49
DWM Exp 2 C49
DWM Exp 2 C49
PART A
(PART A : TO BE REFFERED BY STUDENTS)
Experiment No.02
A.1 Aim:
Implementation of all dimension tables and fact tables related to case
study mentioned in first experiment.
A.2 Prerequisite:
Refer the DBMS manual for SQL Commands and ER diagram.
A.3 Outcome:
After successful completion of this experiment students will be
able to
Model and create schemas for data warehouse.
A.4 Theory:
Algorithm:
CREATION OF OLTP TABLES
1) Customer table
SQL>CREATE TABLE customer
2 ( customer_id VARCHAR2(10) PRIMARY KEY,
3 name VARCHAR2(40) NOT NULL,
4 addr VARCHAR2(10) NOT NULL,
5 dob DATE,
6 in_range NUMBER,
7 h_owner NUMBER,
8 c_owner NUMBER );
The CUSTOMER table is populated using the following sample DML
statemen
3) Trans table
SQL>CREATE TABLE trans
2 ( transid VARCHAR2(20) PRIMARY KEY,
3 custid VARCHAR2(20) REFERENCES
4 customer (customer_id),
5 datet DATE,
6 amt NUMBER,
7 branchid NUMBER(2) );
4) Item_sold table
SQL> CREATE TABLE item_sold
2 ( transid VARCHAR2(20) REFERENCES
trans(transid),
3 itemid VARCHAR2(20) REFERENCES
item(item_id),
4 qty NUMBER);
5) Branch table
SQL>CREATE TABLE branch
2 ( branchid NUMBER(2) PRIMARY
KEY ,
3 street VARCHAR2(54),
4 city VARCHAR2(54),
5 state VARCHAR2(54) );
The BRANCH table is populated using the following DML statement
SQL>INSERT INTO BRANCH VALUES ( ‘Prasad’,
‘Banglore’ ,‘karnataka’ );
PART B
PART B :
(TO BE COMPLETED BY STUDENTS)
Dimension Table
CUSTOMER
CREATE TABLE CUSTOMER
( CUSTOMER_ID VARCHAR2(10) PRIMARY KEY,
NAME VARCHAR2(40) NOT NULL,
GENDER VARCHAR(10) );
Q2: Explain Primary Keys, Surrogate Keys & Foreign Keys with an example.
Ans:
Primary key:
A column or group of columns in a table that helps us to uniquely identifies every row
in that table is called a primary key. This DBMS can't be a duplicate. The same value
can't appear more than once in the table.
Surrogate key:
An artificial key that aims to uniquely identify each record is called a surrogate key.
These kinds of keys are unique because they are created when you don't have any
natural primary key. They do not lend any meaning to the data in the table. The
surrogate key is usually an integer.
Foreign key:
A foreign key is a column that is added to create a relationship with another table.
Foreign keys help us to maintain data integrity and also allows navigation between
two different instances of an entity. Every relationship in the model needs to be
supported by a foreign key.