Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

(TO BE COMPLETED BY STUDENTS)

Roll. No. C43 Name: Aditya Kadam


Class TE C Batch: C3
Experiment No.: 2 Date of Experiment: 25/07/2022
Date of Submission: 31/07/2022 Grade:

B.1 Software Code written by student:


Dealer_dw:
CREATE TABLE dealer_dw (
dealer_ID NUMBER PRIMARY KEY,
location_id NUMBER NOT NULL,
country_id NUMBER NOT NULL,
dealer_name VARCHAR2(10) NOT NULL,
dealer_contact int
);

insert into dealer_dw values(12,11,10,'aditya',9877665544);


insert into dealer_dw values(13,10,09,'sarvesh',9870665544);
insert into dealer_dw values(16,18,05,'sid',9871665544);

Date_dw:
CREATE TABLE date_dw (
date_ID NUMBER PRIMARY KEY,
deal_year NUMBER NOT NULL,
deal_month NUMBER NOT NULL,
quarter NUMBER NOT NULL,
deal_date int
);

insert into date_dw values(12,2019,10,3,13);


insert into dealer_dw values(13,2018,09,2,14);
insert into dealer_dw values(16,2018,05,1,19);
insert into date_dw values(17,2017,04,1,09);

Branch_dw:
CREATE TABLE branch_dw (
branch_ID NUMBER PRIMARY KEY,
branch_name varchar(255) NOT NULL,
branch_addr varchar(255) NOT NULL,
country varchar(255)
);

insert into branch_dw values(102,'electric','sector-20','india');


insert into branch_dw values(103,'transport','sector-10','india');
insert into branch_dw values(109,'optics','sector-30','india');
Product:
CREATE TABLE product(
product_ID NUMBER PRIMARY KEY,
product_name varchar(255) NOT NULL,
model_id int NOT NULL,
varaint_id int
);

insert into product values(111,'soap',333,231);


insert into product values(112,'shampoo',303,291);
insert into product values(113,'biscuit',393,201);

SALE_FACT:
CREATE TABLE SALE_FACT(
dealer_id NUMBER REFERENCES dealer_dw(dealer_id),
product_id NUMBER REFERENCES product(product_id),
branch_id NUMBER REFERENCES branch_dw(branch_id),
date_id NUMBER REFERENCES date_dw(date_id),
units_sold int,
revenue int
);

insert into SALE_FACT values(12,111,102,12,208,10000);


insert into SALE_FACT values(13,112,103,13,500,25000);
insert into SALE_FACT values(16,113,109,16,10000,45000);

B.2 Input and Output:

Dealer_dwTable :
Date_dw Table :

Branch_dw Table:

Product Table :

SALE_FACT Table:
B.3 Observations and learning:
We learn how to create dimention tables using SQL.

B.4 Conclusion:
In this experiment we learn to create star schema model in SQL sheet.

B.5 Question of Curiosity


In this we are able to know how does the fact table is created and implemented.

Q1: What are the differences between Dimension table and fact table?

Fact Table Dimension Table


S.NO

Fact table contains the Dimension table contains the


measuring of the attributes attributes on that truth table
1. of a dimension table. calculates the metric.

In fact table, There is less


attributes than dimension While in dimension table, There is
2. table. more attributes than fact table.

In fact table, There is more


records than dimension While in dimension table, There is
3. table. less records than fact table.

Fact table forms a vertical While dimension table forms a


4. table. horizontal table.

The attribute format of fact


table is in numerical format While the attribute format of
5. and text format. dimension table is in text format.

It comes after dimension


6. table. While it comes before fact table.

The number of fact table is


less than dimension table in While the number of dimension is
7. a schema. more than fact table in a schema.

It is used for analysis While the main task of dimension


purpose and decision table is to store the information about
8. making. a business and its process.
Q2: Explain Primary Keys, Surrogate Keys & Foreign Keys with an example.

Primary key:
Colum that contains value that uniquely identify the each row of the table is called
primary key.

Ex. Student_id ,Adhar number etc.

Surrogate key:
A Surrogate Key in SQL Server is a unique identifier for each row in the table. It is
just a key. Using this key we can identify a unique row. There is no business meaning for
Surrogate Keys.

Foreign key:
A Foreign key is a field (or collection of fields) in one table, that refers to the Primary
key in another table.

You might also like