SlideShare a Scribd company logo
1 of 33
Download to read offline
University of New York, Tirana
M.Sc. in Computer Science
Advanced DatabaseConcepts
Host:
Department of Computer Science
School of Computing and Mathematical Sciences
University ofGreenwich
Partner:
University of New York in Tirana
Student: Ester Daci
Contents
Abstract............................................................................................................3
Introduction .......................................................................................................4
Normalization ..................................................................................................7
Star Schema and introduction of dimensions.............................................................8
Overview ofQuery.............................................................................................. 10
Queries for creating tables of our first database AD.................................................. 10
Queries for creating tables of our first database TOD................................................ 13
Fact table:........................................................................................................................................... 21
RAPORTS ......................................................................................................... 32
References....................................................................................................... 33
Abstract
According to changes that are happening in technology and business nowadays, even Airlines
Companies have to survive in this current competitive environment. Their customer data has
the potential to provide competitive advantage to these organizations.
One of the solutions to do it is by building a data warehouse, which are able to provide any
kind of information to the management level. This will not help the management of
organisations to make strategic decisions, but also will help the company to position in a good
place in the market.
This project is about building a simple data warehouse (data mart) for an Airline Company.
Initially are defined business requirements and is created a conceptual design of the source
databases. This includes collecting information about databases that are going to be included.
Next step is to create tables, relationships and do normalization of the tables.
The last one includes queries for populating and updating the database, and some procedures
to perform all the necessary actions.
Introduction
A data warehouse is a database designed to enable business intelligence activities: it exists to
help users understand and enhance their organization's performance. A data mart serves the
same role as a data warehouse, but it is intentionally limited in scope. It may serve one
particular department or line of business. The advantage of a data mart versus a data warehouse
is that it can be created much faster due to its limited coverage. (oracle.com, n.d.)
Figure.1. Architecture of Data Warehouse
As it is already introduced, in this project we are going to show the steps about building a data
mart for an Airline Company.
Below are shown the tables we are going to use as source in order to implement a data
warehouse in 3rd
normal form.
Figure.2.Tables that represent databases
Two of the biggest databases that the Airline Company has, are Agent_ Detail (AD), in which
is included data about distribution of agents in specific Agencies and Ticket_ Order_ Detail
(TOD). The Agent table contains attributes like Agent_ id, Agency_ id, Agent_ name and
Agent_ surname. The PRIMARY KEY of this table is Agent_ id. The Agency table contains
these attributes: Agency_ id, which is PRIMARY KEY, City, and No_ of_ Agent that a certain
agency has. These two tables are related together through Agency_ id which is a FOREGIN
KEY in Agent Table.
Ticket_ Order_ Detail (TOD) database includes tables like Ticket, Booking Details and
Customer. Ticket table is connected with Booking Detail table, through ticket_ id(PRIMARY
KEY in Ticket table and FOREGIN KEY in Booking Detail). The Agent table is linked with
Ticket table via agent_ id which is a FOREIGN KEY in Ticket table. We have also the
Customer table, which has customer_ id (PRIMARY KEY), agent_ id, customer_ name,
customer_ surname, phone number and age. Agent table is linked with Customer table via
Agent_ id which is a FOREIGN KEY in Customer table.
Now, let’s see for each database, what information includes each table and also analyse this
information. The first database as we said is Agent _Detail (AD). This database includes two
tables: Agent and Agency. The Agent table contains personal information, like agent’s name,
agent’s surname and of course the agency’s id about each agent that works in this Airline
Company. This is one of the most important information needed in building the data
warehouse, because this table gives us the possibility to input the data about agents and then
analyse some reports like the total sales of ticket per agent (based on relationship with other
tables as well). The reports generated will be used by managers of Airline Company for the
bonus schema of their employees based on total sales/agent. Knowing the fact that Agent’s
table include also Agency’s ID as FOREIGN KEY, from this table we can also distinguish the
sales per each agency.
The second table of the first database (AD) is Agency. This table contains attributes like
Agency _ID, City (where a specific agency is located) and number of employees (agents) that
each agency has. In relation with other tables, from this table we can extract necessary
information about total sales for example or time when the most of the tickets are sold. By
owning the reports mentioned, the managers and other departments can make better decisions,
for example the Department of Marketing can make promotions in ticket’s price during the
periods that the sales are increasing. The association between Agent’s table and Agency’s table
will always be one to many, so there are many agents who works in one agency.
Now, let’s analyse the second database Ticket _Order _Detail (TOD) and what information we
can extract by using the data of this database.
Ticket _Order _Detail database include tables like Ticket, Booking _Details and Customer.
The Ticket’s table as we said contains attribute likeTicket_ ID (PRIMARY KEY), Agent_ ID
(FOREIGN KEY), Customer_ ID (FOREIGN KEY), Price and Ticket_ Type (General
admission or VIP).
This table gives the company the necessary information in generating different reports. One
example of the report generated may be “How many customers have bought the VIP ticket” or
“How is the price changed in different periods of time for one special ticket_ type”. The last
two examples of reports and all the others are used by managers, analysts, marketing to enhance
their decision-making activities in order to improve business processes and build a competitive
advantage.
The second table is Booking_ Detail. The attributes included are Booking_ ID (PRIMARY
KEY), Ticket_ ID (FOREIGN KEY), Agent_ ID (FOREIGN KEY), Origin_ Country,
Destination _Country.
The examples of reports extract from this table may include “How many tickets have sold an
agent” or “Which is the most preferred destination country”.
The last table is Customer. This table include a general information about the clients of the
Airline Company. The attributes of Customer’s table are Customer_ ID, Agent_ ID, Customer_
name, customer_ surname, phone number and age. This type of information gives the company
the possibility to classify and analyse their customer. By generating different reports for
example “What is the average age of the customers that have ordered a VIP ticket” or “How
many customers have selected a certain destination country”.
Ticket table and Booking_ Detail table are associated with a relationship one to one with each
other. Customer Table is associated with Agent Table in AD database, with a relationship many
to many in that sense that one agent can serve to many clients, but even one client can be served
by many agents. So one client can order a ticket in different agency.
In the next sections, there is Entity Relationship Schema of Airline Company database in 3rd
normal form, also the star schema that introduces all the dimensions that are going to be taken
in consideration in this data modelling for the data mart of an Airline Comany.
Normalization
Database normalization is a technique of organizing the data in the database. Normalization is
a formal approach that applies a set of rules to associate attributes with entities. Normalization
is used when designing a database. (datanamic.com, n.d.)
Normalization is a data design process that has a high level goal of keeping each fact in just
one place to avoid data redundancy and insert, update, and delete anomalies. (oracle.com, n.d.)
Data model after Normalization:
Figure.3.Entity Relationship Schema
Star Schema and introduction of dimensions
The term star schema is a way of referring to a "dimensional modeling" approach to defining
your data model. Most descriptions of dimensional modeling use terminology drawn from the
work of Ralph Kimball, the pioneering consultant and writer in this field. Dimensional
modeling creates multiple star schemas, each based on a business process such as sales or
marketing. Star schemas divide data into facts and dimensions. Facts are the measurements of
some event such as a sale and are typically numbers. Dimensions are the categories you use to
identify facts, such as date, location, and product. (oracle.com, n.d.)
In the figure below there is the star schema of our database:
Figure.4: Star Schema
In our example there are 3 dimensions: Customer, Agent and Time Dimension.
 Customer describes each customer based on their attributes identified by customer_ ID.
 Agent describes each agent of this company identified by agent_ ID.
 Time is the time of the flights.
The fact refers to every dimension. The association between the fact and the dimension is
always one to any, which means each fact is associated with exactly one unit of the single
dimension, and each unit of the dimension can be associated with any number of facts
(including 0). (Gornik, n.d.)
The dimension Agent will have three levels and one hierarchy:
 Total
 Agency
 Agent
The attributes for agent dimension are:
 agent fullname(firstname+lastname)
 agentid
 sourceid
Also, the dimension Customer will have three levels and one hierarchy:
 Total
 Age
 Customer
The attributes for agency dimension:
 agencyid
 sourceid
The dimension Time will have three levels and one hierarchy:
 Total
 Year
 Month
Attributes for the year:
 Year
Attributes for the month:
 Month name
 Description
 Quarter
Measures that going to be part are:
 Total amount
 Number of tickets sold
Overview ofQuery
In the first chapter we describe both the physical design and logical design of our data
warehouse.
In this chapter we are going to describe and show all the query needed to perform different
actions until we will implement the whole data warehouse for our Airline Company.
CREATE USERS…
CREATE TABLES…
SELECT…
INSERT… etc.
Queries for creating tables of our first database AD.
First of all we are going to create a user named ad. The commands used in CMD are:
SQL> CREATE USER ad IDENTIFIED BY ad;
User created.
SQL> GRANT Create Session TO ad;
Then, we create a new connection, and after this we start by creating tables:
Queries used for this are:
CREATE TABLE ad.Agency
( AgencyId number NOT NULL PRIMARY KEY, -- primary key column
City varchar2(50) NOT NULL,
NoOfAgents number NOT NULL
);
For populating the Agency table write the INSERT statement. For example:
INSERT INTO ad.Agency (AgencyId, City, NoOfAgents)
VALUES (1,'Tirana', 3);
The result after SELECT * from ad.Agency; is:
The second table of this database is Agent:
CREATE TABLE ad.Agent
(
AgentId number NOT NULL PRIMARY KEY, -- primary key column
AgencyId number NOT NULL,
AgentName varchar2(50) NOT NULL,
AgentSurname varchar2(50) NOT NULL,
CONSTRAINT FK_AgentWorks
FOREIGN KEY (AgencyId ) REFERENCES ad.Agency(AgencyId));
The first instance:
INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname)
VALUES (1, 1,'John', 'Miller');
INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname)
VALUES (2, 1,'Keith','Armstrong');
INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname)
VALUES (3, 1,'Donna','Anderson');
INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname)
VALUES (4, 2,'Janet','Bell');
INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname)
VALUES (5, 2,'Rose','Saunders');
INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname)
VALUES (6, 2,'Scott','Simpson');
INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname)
VALUES (7, 3,'Steve','Thompson');
INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname)
VALUES (8, 3,'Sam','White');
INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname)
VALUES (9, 3,'Sam','White');
INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname)
VALUES (10, 4,'Maria','Adams');
INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname)
VALUES (11, 4,'Lili','Allen');
The next step is creating the other user TOD, that is going to use as a source database too.
create user tod identified by tod;
grant create session to tod;
grant resource to tod;
alter user tod default role resource;
Queries for creating tables of our first database TOD.
After this, just like we did for the first database, we now can create the third tables of the second
database.
CREATE TABLE tod.customer
(
CustomerId number NOT NULL PRIMARY KEY, -- primary key column
agencyid number NOT NULL,
CustomerName varchar2(50) NOT NULL,
CustomerSurbame varchar2(50) NOT NULL,
Age number NOT NULL,
PhoneNumber number NOT NULL);
CREATE TABLE tod.BookingDetails
(
BookingId number NOT NULL PRIMARY KEY, -- primary key column
TicketId number NOT NULL,
AgentId number NOT NULL,
OriginCountry varchar2(50) NOT NULL,
DestinationCountry varchar2(50) NOT NULL,
CONSTRAINT FK_Booking_Ticket
FOREIGN KEY (TicketId) REFERENCES tod.Ticket(TicketId));
CREATE TABLE tod.Ticket
(
TicketId number NOT NULL PRIMARY KEY, -- primary key column
AgentId number NOT NULL,
CustomerId number NOT NULL,
Price number NOT NULL,
TicketType varchar2(50) NOT NULL,
CONSTRAINT FK_Cust_Ticket
FOREIGN KEY (CustomerId) REFERENCES tod.Customer(CustomerId)
);
After creating these tables, it should be displayed the below result:
And the INSERT statement for the tables BOOKING DETAILS, TICKET and CUSTOMER
is as follows:
INSERT INTO tod.customer VALUES (101, 1,'Dave','Smith', 24, 35569878);
INSERT INTO tod.customer VALUES (102, 1,'Ivan','Brown', 30, 35569585);
INSERT INTO tod.customer VALUES (103, 2,'Ramon','King', 23, 35421412);
INSERT INTO tod.customer VALUES (104, 2,'Ester','Moore', 44, 3521352);
INSERT INTO tod.customer VALUES (105, 4,'Jorge','Lopez', 45, 35252512);
INSERT INTO tod.customer VALUES (106, 3,'Roberto','Miller', 35, 3522511);
INSERT INTO tod.customer VALUES (107, 5,'Nathaniel','Wilson', 55, 35263611);
INSERT INTO tod.customer VALUES (108, 6,'Claude','Hill', 51, 352652511);
INSERT INTO tod.customer VALUES (109, 6,'Ethan','Taylor', 31, 352652513);
INSERT INTO tod.customer VALUES (110, 7,'Lewis','Jackson', 31, 3526587813);
INSERT INTO tod.customer VALUES (111, 7,'Glen','Nelson', 29, 3526587813);
INSERT INTO tod.customer VALUES (112, 8,'Joshua','Thomas',59, 38887813);
INSERT INTO tod.customer VALUES (113, 9,'Peter','Harris', 39, 38855513);
INSERT INTO tod.customer VALUES (114, 10,'Shane','Cooper', 20, 388544443);
INSERT INTO tod.customer VALUES (115, 11,'Aaron','Mitchell', 35, 35555443);
COMMIT;
Write: select * from tod.customer;
The population of the second table:
INSERT INTO tod.Ticket VALUES (1, 1, 101, 35,'General admission');
INSERT INTO tod.Ticket VALUES (2, 1, 102, 55,'General admission');
INSERT INTO tod.Ticket VALUES (3, 1, 101, 105,'VIP');
INSERT INTO tod.Ticket VALUES (4, 2, 103, 111,'General admission');
INSERT INTO tod.Ticket VALUES (5, 2, 101, 222,'VIP');
INSERT INTO tod.Ticket VALUES (6, 3, 104, 202,'General admission');
INSERT INTO tod.Ticket VALUES (7, 4, 105, 41,'General admission');
INSERT INTO tod.Ticket VALUES (8, 6, 106, 102,'General admission');
INSERT INTO tod.Ticket VALUES (9, 7, 106, 23,'General admission');
INSERT INTO tod.Ticket VALUES (10, 7, 106, 255,'VIP');
INSERT INTO tod.Ticket VALUES (11, 8, 107, 95,'General admission');
INSERT INTO tod.Ticket VALUES (12, 8, 101, 105,'General admission');
INSERT INTO tod.Ticket VALUES (13, 9, 108, 75,'General admission');
INSERT INTO tod.Ticket VALUES (14, 9, 109, 35,'General admission');
INSERT INTO tod.Ticket VALUES (15, 10, 111, 35,'General admission');
INSERT INTO tod.Ticket VALUES (16, 11, 110, 55,'General admission');
INSERT INTO tod.Ticket VALUES (17, 11, 114, 102,'General admission');
INSERT INTO tod.Ticket VALUES (18, 11, 115, 52,'General admission');
INSERT INTO tod.Ticket VALUES (19, 9, 113, 111,'VIP');
INSERT INTO tod.Ticket VALUES (20, 11, 112, 101,'General admission');
COMMIT;
Write: Select * from tod.Ticket;
The population of the third table:
INSERT INTO tod.BookingDetails VALUES (10, 1, 1,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (11, 2, 2,'Italy','Albania');
INSERT INTO tod.BookingDetails VALUES (12, 3, 3,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (13, 4, 4,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (14, 5, 5,'Italy','Albania');
INSERT INTO tod.BookingDetails VALUES (15, 6, 6,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (16, 7, 7,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (17, 7, 7,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (18, 8, 8,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (19, 9, 9,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (20, 10, 10,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (21, 11, 11,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (22, 12, 1,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (23, 13, 2,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (24, 14, 3,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (26, 15, 4,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (27, 16, 5,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (28, 17, 6,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (29, 18, 7,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (29, 18, 7,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (29, 19, 8,'Albania','Italy');
INSERT INTO tod.BookingDetails VALUES (30, 20, 9,'Italy','Albania');
COMMIT;
Write: select * from tod.BookingDetails;
Once we have created the tables as sysdba, we create user dataw, in order to use as our data
warehouse.
create user dataw identified by dataw
default tablespace USERS
temporary tablespace USERS
account unlock;
grant create session to dataw;
grant resource to dataw;
alter user dataw default role resource;
As we did for the first databases, as user dataw we have to create tables based on dimensions
we have determined. Two tables we are going to use are table agent and table customer, and
fact_table.
CREATE TABLE agent(
id number(6,0) PRIMARY KEY,
id_total number(6,0),
total varchar2(30),
idagency number (6,0),
agencySourceId number (6,0),
agentid number (6,0),
fullname varchar2(46),
agent_source_id number (6,0)
)
CREATE TABLE customer(
id number(6,0) PRIMARY KEY,
id_total number(6,0),
total varchar2(30),
avg_age number (6,0),
custid number (6,0),
cust_fullname varchar2(46),
cust_source_id number (6,0)
)
select * from dataw.agent;
select * from dataw.customer;
Fact table:
CREATE TABLE fact_table(
time_id number(6, 0),
agent_id number(6, 0),
customer_id number(6,0),
amount NUMBER(8,2),
no_tickets number(6,0),
CONSTRAINT "agent_id_FK" FOREIGN KEY (agent_id)
REFERENCES dataw.agent(id),
CONSTRAINT "customer_id_FK" FOREIGN KEY (customer_id)
REFERENCES dataw.customer(id),
CONSTRAINT "pk" PRIMARY KEY (agent_id, customer_id,time_id));
Write: select * from dataw.fact_table; we can see all the attributes added in fact_table:
In order to have access in two source databases, we should grant access to the target schema as
sysdba:
grant select on ad.agent to dataw;
grant select on ad.agency to dataw;
grant select on tod.BookingDetails to dataw;
grant select on tod.customer to dataw;
grant select on tod.ticket to dataw;
The CREATE SEQUENCE statement allows you to create a new sequence in the database.
Create the sequence for the dimension agent.
create sequence seq_agent
start with 1
increment by 1;
Create the sequence for the dimension customer.
create sequence seq_cust
start with 1
increment by 1;
Next step is to fill the two tables we created on dataw, with values:
insert into agent (id, total) values ( seq_agent.nextval,'All agents');
update agent set id_total=id;
Write: select * from dataw.agent;
Once we have created the two tables in dataw schema, now we have to insert the values. The
values will be taken from our two source databases AD and TOD. We have determined the
Agent dimension with three levels: Total, Agency and Agent.
The population of data warehouse will become by filling one by one the dimensions:
1) Fill the agency level
As sysdba grant access to the target schema to select the source tables:
grant select on ad.agency to dataw;
Now we can write INSERT statement:
insert into agent(id,id_total, total, agencySourceId )
select seq_agent.nextval,
a.id_total,
a.total,
AgencyId as agencySourceId
from ad.agency cross join agent a;
update agent set idagency=id where agencySourceId is not null;
Write: select * from dataw.agent;
2) Fill the agent level:
insert into agent (id, id_total, total,idagency , agencySourceId , fullname,agent_source_id)
select seq_agent.nextval,
a.id_total,
a.total,
a.idagency,
a.agencySourceId,
source.AgentName || ' ' || source.AgentSurname as fullname,
source.AgentId as source_id
from ad.Agent source join agent a on source.AgencyId=a.agencySourceId;
3) Insert values in Customer Table
3.1) Fill the TOTAL level
insert into customer (id, total) values ( seq_cust.nextval,'All customers');
update customer set id_total=id;
Write: select * from customer;
In customer table, we are going to made a change. A new attribute age_source_id will be added,
by using ALTER statement:
ALTER TABLE customer
ADD age_source_id number;
3.2) Fill the age level:
insert into customer(id, id_total, total, avg_age, age_source_id)
select
seq_cust.nextval as id, c.id_total, c.total,source.age, source.customerid
from tod.customer source cross join customer c;
3.3) Fill the customer level:
insert into customer(id, id_total, total, avg_age, age_source_id,cust_fullname, cust_source_id)
select seq_cust.nextval as id,
target.id_total,
target.total,
target.avg_age,
target.age_source_id,
source.customername || ' '|| source.customersurbame as fullname,
source.CustomerId as cust_source_id
from tod.customer source join customer target on source.CustomerId =target.age_source_id;
update customer set custid =id where cust_source_id is not null;
The last dimension that is needed to take into consideration is TIME DIMENSION. Let’s start with
creation of tables one by one:
create table TIME(
id number(6,0) primary key,
id_total number(6,0),
total varchar2(20),
id_year number(6,0),
year number(4),
id_month number(6,0),
month number(2),
description varchar2(20),
quarter number(1)
)
As we did for the other tables, the next step is to create the time sequence:
create sequence time_seq
start with 1
increment by 1;
1) Fill the total level
insert into TIME (id,total) values (TIME_SEQ.nextval,'All years');
update time set id_total=id;
2) Create the procedure to insert records for the years
create or replace PROCEDURE add_years
( first_year number, second_year number )
IS
y number;
BEGIN
y:=first_year;
while (y <=second_year)
loop
insert into time (id,id_total, total, year)
select time_seq.nextval,id_total, total,y from time
where year is null;
y:=y+1;
end loop;
END add_years;
3) EXECUTE the procedure add_years
exec add_years(2001,2010);
update time set id_year=id where year is not null;
4) Insert the records for the months
insert into time(id, id_total, total, id_year, year,month, description, quarter )
select time_seq.nextval , t.id_total, t.total, t.id_year, t.year,
months.month, months.descr, months.quarter
from time t cross join
(
select 1 month, 'Jan' Descr, 1 Quarter from dual
union
select 2 month, 'Feb' Descr, 1 Quarter from dual
union
select 3 month, 'Mar' Descr, 1 Quarter from dual
union
select 4 month, 'Apr' Descr, 2 Quarter from dual
union
select 5 month, 'May' Descr, 2 Quarter from dual
union
select 6 month, 'Jun' Descr, 2 Quarter from dual
union
select 7 month, 'Jul' Descr, 3 Quarter from dual
union
select 8 month, 'Aug' Descr, 3 Quarter from dual
union
select 9 month, 'Sep' Descr, 3 Quarter from dual
union
select 10 month, 'Oct' Descr, 4 Quarter from dual
union
select 11 month, 'Nov' Descr, 4 Quarter from dual
union
select 12 month, 'Dec' Descr, 4 Quarter from dual
) months
where t.id_year is not null;
update time set id_month=id where month is not null;
Fact_Table is the last table, we are going to INSERT values. One last thing except dimensions
are measures Total amount and number of tickets sold. In order to determine time dimension,
it is needed to add another attribute ticket_date, in Ticket table, in the second database TOD.
alter table ticket add ticket_date number(10);
Let’s update the new column:
update tod.ticket set ticket_date = 10112019 where TicketId =1;
update tod.ticket set ticket_date = 10122019 where TicketId =2;
update tod.ticket set ticket_date = 11112019 where TicketId =3;
update tod.ticket set ticket_date = 12112019 where TicketId =4;
update tod.ticket set ticket_date = 13112019 where TicketId =5;
update tod.ticket set ticket_date = 14112019 where TicketId =6;
update tod.ticket set ticket_date = 15112019 where TicketId =7;
update tod.ticket set ticket_date = 16112019 where TicketId =8;
update tod.ticket set ticket_date = 17112019 where TicketId =9;
update tod.ticket set ticket_date = 21112019 where TicketId =10;
update tod.ticket set ticket_date = 22112019 where TicketId =11;
update tod.ticket set ticket_date = 23112019 where TicketId =12;
update tod.ticket set ticket_date = 24112019 where TicketId =13;
update tod.ticket set ticket_date = 24122019 where TicketId =14;
update tod.ticket set ticket_date = 25112019 where TicketId =15;
update tod.ticket set ticket_date = 26112019 where TicketId =16;
update tod.ticket set ticket_date = 27112019 where TicketId =17;
update tod.ticket set ticket_date = 28112019 where TicketId =18;
update tod.ticket set ticket_date = 29112019 where TicketId =19;
update tod.ticket set ticket_date = 30112019 where TicketId =20;
Now, we have to INSERT values in fact_table.
insert into fact_table (agent_id, customer_id,time_id, amount,no_tickets)
select t.id, a.id, c.id,
sum(source.price) as amount,
count(source.TicketId) as no_tickets
from
tod.ticket source join customer c on source.CustomerId=c.cust_source_id
join agent a on source.TicketId=a.AgentId
join time t on (to_char(ticket_date,'yyyy')=t.year
and to_char(ticket_date,'mm')=t.month)
group by t.id,a.id, c.id
order by t.id,a.id, c.id;
RAPORTS
Below are some raports based on information above that we inserted in our data warehouse user:
1)Suppose we want the amount based on price of ticket sold per each agent and per each agent we
need fullname and agent id. In dataw, write the below query:
select agent_id,fullname,amount form fact_table join agent on fact_table.agent_id=agent.agentid;
2)The second would be the number of tickets that each customer has bought in this company:
Select customer_id,no_tickets from fact_table join customer on
fact_table.customer_id=customer.custid;
3)All the tickets sold in December
Select no_ticket,time from fact_table where time between ‘01122019’ and ‘31122019’;
4)Average age of customers
Select custid,cust_fullname, sum(avg_age)/2 as ‘avarage age’ from customer;
5)Number of tickets sold per each agency.
Select id_agency,no_tickets from fact_table join agent on fact_table.agent_id=agent.agentid;
References
datanamic.com. (n.d.). https://www.datanamic.com/support/database-normalization.html.
Retrieved from https://www.datanamic.com/support/database-normalization.html.
Gornik, D. (n.d.). https://www.techwell.com/sites/default/files/articles/XUS2170853file1_0.pdf.
Retrieved from
https://www.techwell.com/sites/default/files/articles/XUS2170853file1_0.pdf.
oracle.com.(n.d.). https://docs.oracle.com/database/121/DWHSG/E41670-11.pdf.Retrievedfrom
https://docs.oracle.com/database/121/DWHSG/E41670-11.pdf:
https://docs.oracle.com/database/121/DWHSG/E41670-11.pdf

More Related Content

What's hot

Physical data modeling
Physical data modelingPhysical data modeling
Physical data modelingAbbas Ahmed
 
MS Office Access Tutorial
MS Office Access TutorialMS Office Access Tutorial
MS Office Access TutorialvirtualMaryam
 
Ecdl v5 module 5 print
Ecdl v5 module 5 printEcdl v5 module 5 print
Ecdl v5 module 5 printMichael Lew
 
Access 2007-Datasheets 1-Create a table by entering data
Access 2007-Datasheets 1-Create a table by entering dataAccess 2007-Datasheets 1-Create a table by entering data
Access 2007-Datasheets 1-Create a table by entering dataOklahoma Dept. Mental Health
 
Introduction to Data Warehousing
Introduction to Data WarehousingIntroduction to Data Warehousing
Introduction to Data WarehousingAnimesh Srivastava
 
ECDL module 5: using databases [To be continued]
ECDL module 5: using databases [To be continued] ECDL module 5: using databases [To be continued]
ECDL module 5: using databases [To be continued] Hassan Ayad
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms accessjigeno
 
Microsoft Access Notes 2007 Ecdl
Microsoft Access Notes 2007 EcdlMicrosoft Access Notes 2007 Ecdl
Microsoft Access Notes 2007 EcdlRichard Butler
 
Lession 6.introduction to records
Lession 6.introduction to recordsLession 6.introduction to records
Lession 6.introduction to recordsĐỗ Đức Hùng
 
Tutorial for using SQL in Microsoft Access
Tutorial for using SQL in Microsoft AccessTutorial for using SQL in Microsoft Access
Tutorial for using SQL in Microsoft Accessmcclellm
 
MS Access Ch 2 PPT
MS Access Ch 2 PPTMS Access Ch 2 PPT
MS Access Ch 2 PPTprsmith72
 
Ms access notes
Ms access notesMs access notes
Ms access notesIKIARA
 
Ms access tutorial
Ms access tutorialMs access tutorial
Ms access tutorialminga48
 

What's hot (20)

Physical data modeling
Physical data modelingPhysical data modeling
Physical data modeling
 
MS Office Access Tutorial
MS Office Access TutorialMS Office Access Tutorial
MS Office Access Tutorial
 
Ecdl v5 module 5 print
Ecdl v5 module 5 printEcdl v5 module 5 print
Ecdl v5 module 5 print
 
Access 2007-Datasheets 1-Create a table by entering data
Access 2007-Datasheets 1-Create a table by entering dataAccess 2007-Datasheets 1-Create a table by entering data
Access 2007-Datasheets 1-Create a table by entering data
 
Introduction to Data Warehousing
Introduction to Data WarehousingIntroduction to Data Warehousing
Introduction to Data Warehousing
 
Ms access 2007 pptx
Ms access 2007 pptxMs access 2007 pptx
Ms access 2007 pptx
 
ECDL module 5: using databases [To be continued]
ECDL module 5: using databases [To be continued] ECDL module 5: using databases [To be continued]
ECDL module 5: using databases [To be continued]
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms access
 
Databases By ZAK
Databases By ZAKDatabases By ZAK
Databases By ZAK
 
Microsoft Access Notes 2007 Ecdl
Microsoft Access Notes 2007 EcdlMicrosoft Access Notes 2007 Ecdl
Microsoft Access Notes 2007 Ecdl
 
Lession 6.introduction to records
Lession 6.introduction to recordsLession 6.introduction to records
Lession 6.introduction to records
 
Tutorial for using SQL in Microsoft Access
Tutorial for using SQL in Microsoft AccessTutorial for using SQL in Microsoft Access
Tutorial for using SQL in Microsoft Access
 
Access 2007
Access 2007Access 2007
Access 2007
 
Leisure Life E-Commerce Bookstore
Leisure Life E-Commerce BookstoreLeisure Life E-Commerce Bookstore
Leisure Life E-Commerce Bookstore
 
MS Access Ch 2 PPT
MS Access Ch 2 PPTMS Access Ch 2 PPT
MS Access Ch 2 PPT
 
MS Access Training
MS Access TrainingMS Access Training
MS Access Training
 
Ms access notes
Ms access notesMs access notes
Ms access notes
 
Uses of MS Access in Business
Uses of MS Access in BusinessUses of MS Access in Business
Uses of MS Access in Business
 
Access 2007 lecture notes students
Access 2007 lecture notes studentsAccess 2007 lecture notes students
Access 2007 lecture notes students
 
Ms access tutorial
Ms access tutorialMs access tutorial
Ms access tutorial
 

Similar to Building a data warehouse

Data Modeling PPT
Data Modeling PPTData Modeling PPT
Data Modeling PPTTrinath
 
Running Head PROJECT DELIVERABLE 31PROJECT DELIVERABLE 310.docx
Running Head PROJECT DELIVERABLE 31PROJECT DELIVERABLE 310.docxRunning Head PROJECT DELIVERABLE 31PROJECT DELIVERABLE 310.docx
Running Head PROJECT DELIVERABLE 31PROJECT DELIVERABLE 310.docxtodd581
 
Case study: Implementation of dimension table and fact table
Case study: Implementation of dimension table and fact tableCase study: Implementation of dimension table and fact table
Case study: Implementation of dimension table and fact tablechirag patil
 
ARIS_Basic_Cheat_Sheet.pdf
ARIS_Basic_Cheat_Sheet.pdfARIS_Basic_Cheat_Sheet.pdf
ARIS_Basic_Cheat_Sheet.pdfalexandre929334
 
System Data Modelling Tools
System Data Modelling ToolsSystem Data Modelling Tools
System Data Modelling ToolsLiam Dunphy
 
Elements_Cheat_Sheet.pdf
Elements_Cheat_Sheet.pdfElements_Cheat_Sheet.pdf
Elements_Cheat_Sheet.pdfbandi25
 
topic 2 data flow daigram topic-converted.pdf
topic 2 data flow daigram topic-converted.pdftopic 2 data flow daigram topic-converted.pdf
topic 2 data flow daigram topic-converted.pdftahir427002
 
Wind Turbine Fuzzy Logic Simulink Matalb Model.pdf
Wind Turbine Fuzzy Logic Simulink Matalb Model.pdfWind Turbine Fuzzy Logic Simulink Matalb Model.pdf
Wind Turbine Fuzzy Logic Simulink Matalb Model.pdfIbrar Hussain
 
Data resource management
Data resource managementData resource management
Data resource managementNirajan Silwal
 
(Lecture 3) Star Schema.pdf
(Lecture 3) Star Schema.pdf(Lecture 3) Star Schema.pdf
(Lecture 3) Star Schema.pdfMobeenMasoudi
 
Data flow diagrams dfd
Data flow diagrams dfdData flow diagrams dfd
Data flow diagrams dfdAlam Fareed
 
It 302 computerized accounting (week 2) - sharifah
It 302   computerized accounting (week 2) - sharifahIt 302   computerized accounting (week 2) - sharifah
It 302 computerized accounting (week 2) - sharifahalish sha
 
Chap7-Multidimensional data modeling.pptx
Chap7-Multidimensional data modeling.pptxChap7-Multidimensional data modeling.pptx
Chap7-Multidimensional data modeling.pptxMOHDAIMANFARHANBINMO
 
Inventory management system
Inventory management systemInventory management system
Inventory management systempavanwalecha
 

Similar to Building a data warehouse (20)

Data Modeling PPT
Data Modeling PPTData Modeling PPT
Data Modeling PPT
 
Running Head PROJECT DELIVERABLE 31PROJECT DELIVERABLE 310.docx
Running Head PROJECT DELIVERABLE 31PROJECT DELIVERABLE 310.docxRunning Head PROJECT DELIVERABLE 31PROJECT DELIVERABLE 310.docx
Running Head PROJECT DELIVERABLE 31PROJECT DELIVERABLE 310.docx
 
Data Modelling..pptx
Data Modelling..pptxData Modelling..pptx
Data Modelling..pptx
 
Experiment no 6
Experiment no 6Experiment no 6
Experiment no 6
 
Case study: Implementation of dimension table and fact table
Case study: Implementation of dimension table and fact tableCase study: Implementation of dimension table and fact table
Case study: Implementation of dimension table and fact table
 
Hh
HhHh
Hh
 
ARIS_Basic_Cheat_Sheet.pdf
ARIS_Basic_Cheat_Sheet.pdfARIS_Basic_Cheat_Sheet.pdf
ARIS_Basic_Cheat_Sheet.pdf
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
 
System Data Modelling Tools
System Data Modelling ToolsSystem Data Modelling Tools
System Data Modelling Tools
 
Elements_Cheat_Sheet.pdf
Elements_Cheat_Sheet.pdfElements_Cheat_Sheet.pdf
Elements_Cheat_Sheet.pdf
 
topic 2 data flow daigram topic-converted.pdf
topic 2 data flow daigram topic-converted.pdftopic 2 data flow daigram topic-converted.pdf
topic 2 data flow daigram topic-converted.pdf
 
Wind Turbine Fuzzy Logic Simulink Matalb Model.pdf
Wind Turbine Fuzzy Logic Simulink Matalb Model.pdfWind Turbine Fuzzy Logic Simulink Matalb Model.pdf
Wind Turbine Fuzzy Logic Simulink Matalb Model.pdf
 
Data resource management
Data resource managementData resource management
Data resource management
 
(Lecture 3) Star Schema.pdf
(Lecture 3) Star Schema.pdf(Lecture 3) Star Schema.pdf
(Lecture 3) Star Schema.pdf
 
Data flow diagrams dfd
Data flow diagrams dfdData flow diagrams dfd
Data flow diagrams dfd
 
It 302 computerized accounting (week 2) - sharifah
It 302   computerized accounting (week 2) - sharifahIt 302   computerized accounting (week 2) - sharifah
It 302 computerized accounting (week 2) - sharifah
 
Chap7-Multidimensional data modeling.pptx
Chap7-Multidimensional data modeling.pptxChap7-Multidimensional data modeling.pptx
Chap7-Multidimensional data modeling.pptx
 
Data modelling interview question
Data modelling interview questionData modelling interview question
Data modelling interview question
 
inventory management system
 inventory management system inventory management system
inventory management system
 
Inventory management system
Inventory management systemInventory management system
Inventory management system
 

More from Ester Daci

Projekt-Ekonometrie.
Projekt-Ekonometrie.Projekt-Ekonometrie.
Projekt-Ekonometrie.Ester Daci
 
KodheliDaciKratellariLekaj
KodheliDaciKratellariLekajKodheliDaciKratellariLekaj
KodheliDaciKratellariLekajEster Daci
 

More from Ester Daci (6)

mis
mismis
mis
 
Projekt-Ekonometrie.
Projekt-Ekonometrie.Projekt-Ekonometrie.
Projekt-Ekonometrie.
 
projekti-spss
projekti-spssprojekti-spss
projekti-spss
 
projkti-ssh
projkti-sshprojkti-ssh
projkti-ssh
 
C++-Projekt
C++-ProjektC++-Projekt
C++-Projekt
 
KodheliDaciKratellariLekaj
KodheliDaciKratellariLekajKodheliDaciKratellariLekaj
KodheliDaciKratellariLekaj
 

Recently uploaded

Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAbdelrhman abooda
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...ThinkInnovation
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Sapana Sha
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home ServiceSapana Sha
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 

Recently uploaded (20)

Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 

Building a data warehouse

  • 1. University of New York, Tirana M.Sc. in Computer Science Advanced DatabaseConcepts Host: Department of Computer Science School of Computing and Mathematical Sciences University ofGreenwich Partner: University of New York in Tirana Student: Ester Daci
  • 2. Contents Abstract............................................................................................................3 Introduction .......................................................................................................4 Normalization ..................................................................................................7 Star Schema and introduction of dimensions.............................................................8 Overview ofQuery.............................................................................................. 10 Queries for creating tables of our first database AD.................................................. 10 Queries for creating tables of our first database TOD................................................ 13 Fact table:........................................................................................................................................... 21 RAPORTS ......................................................................................................... 32 References....................................................................................................... 33
  • 3. Abstract According to changes that are happening in technology and business nowadays, even Airlines Companies have to survive in this current competitive environment. Their customer data has the potential to provide competitive advantage to these organizations. One of the solutions to do it is by building a data warehouse, which are able to provide any kind of information to the management level. This will not help the management of organisations to make strategic decisions, but also will help the company to position in a good place in the market. This project is about building a simple data warehouse (data mart) for an Airline Company. Initially are defined business requirements and is created a conceptual design of the source databases. This includes collecting information about databases that are going to be included. Next step is to create tables, relationships and do normalization of the tables. The last one includes queries for populating and updating the database, and some procedures to perform all the necessary actions.
  • 4. Introduction A data warehouse is a database designed to enable business intelligence activities: it exists to help users understand and enhance their organization's performance. A data mart serves the same role as a data warehouse, but it is intentionally limited in scope. It may serve one particular department or line of business. The advantage of a data mart versus a data warehouse is that it can be created much faster due to its limited coverage. (oracle.com, n.d.) Figure.1. Architecture of Data Warehouse As it is already introduced, in this project we are going to show the steps about building a data mart for an Airline Company. Below are shown the tables we are going to use as source in order to implement a data warehouse in 3rd normal form.
  • 5. Figure.2.Tables that represent databases Two of the biggest databases that the Airline Company has, are Agent_ Detail (AD), in which is included data about distribution of agents in specific Agencies and Ticket_ Order_ Detail (TOD). The Agent table contains attributes like Agent_ id, Agency_ id, Agent_ name and Agent_ surname. The PRIMARY KEY of this table is Agent_ id. The Agency table contains these attributes: Agency_ id, which is PRIMARY KEY, City, and No_ of_ Agent that a certain agency has. These two tables are related together through Agency_ id which is a FOREGIN KEY in Agent Table. Ticket_ Order_ Detail (TOD) database includes tables like Ticket, Booking Details and Customer. Ticket table is connected with Booking Detail table, through ticket_ id(PRIMARY KEY in Ticket table and FOREGIN KEY in Booking Detail). The Agent table is linked with Ticket table via agent_ id which is a FOREIGN KEY in Ticket table. We have also the Customer table, which has customer_ id (PRIMARY KEY), agent_ id, customer_ name, customer_ surname, phone number and age. Agent table is linked with Customer table via Agent_ id which is a FOREIGN KEY in Customer table. Now, let’s see for each database, what information includes each table and also analyse this information. The first database as we said is Agent _Detail (AD). This database includes two tables: Agent and Agency. The Agent table contains personal information, like agent’s name, agent’s surname and of course the agency’s id about each agent that works in this Airline Company. This is one of the most important information needed in building the data warehouse, because this table gives us the possibility to input the data about agents and then analyse some reports like the total sales of ticket per agent (based on relationship with other tables as well). The reports generated will be used by managers of Airline Company for the bonus schema of their employees based on total sales/agent. Knowing the fact that Agent’s table include also Agency’s ID as FOREIGN KEY, from this table we can also distinguish the sales per each agency. The second table of the first database (AD) is Agency. This table contains attributes like Agency _ID, City (where a specific agency is located) and number of employees (agents) that each agency has. In relation with other tables, from this table we can extract necessary information about total sales for example or time when the most of the tickets are sold. By
  • 6. owning the reports mentioned, the managers and other departments can make better decisions, for example the Department of Marketing can make promotions in ticket’s price during the periods that the sales are increasing. The association between Agent’s table and Agency’s table will always be one to many, so there are many agents who works in one agency. Now, let’s analyse the second database Ticket _Order _Detail (TOD) and what information we can extract by using the data of this database. Ticket _Order _Detail database include tables like Ticket, Booking _Details and Customer. The Ticket’s table as we said contains attribute likeTicket_ ID (PRIMARY KEY), Agent_ ID (FOREIGN KEY), Customer_ ID (FOREIGN KEY), Price and Ticket_ Type (General admission or VIP). This table gives the company the necessary information in generating different reports. One example of the report generated may be “How many customers have bought the VIP ticket” or “How is the price changed in different periods of time for one special ticket_ type”. The last two examples of reports and all the others are used by managers, analysts, marketing to enhance their decision-making activities in order to improve business processes and build a competitive advantage. The second table is Booking_ Detail. The attributes included are Booking_ ID (PRIMARY KEY), Ticket_ ID (FOREIGN KEY), Agent_ ID (FOREIGN KEY), Origin_ Country, Destination _Country. The examples of reports extract from this table may include “How many tickets have sold an agent” or “Which is the most preferred destination country”. The last table is Customer. This table include a general information about the clients of the Airline Company. The attributes of Customer’s table are Customer_ ID, Agent_ ID, Customer_ name, customer_ surname, phone number and age. This type of information gives the company the possibility to classify and analyse their customer. By generating different reports for example “What is the average age of the customers that have ordered a VIP ticket” or “How many customers have selected a certain destination country”. Ticket table and Booking_ Detail table are associated with a relationship one to one with each other. Customer Table is associated with Agent Table in AD database, with a relationship many to many in that sense that one agent can serve to many clients, but even one client can be served by many agents. So one client can order a ticket in different agency. In the next sections, there is Entity Relationship Schema of Airline Company database in 3rd normal form, also the star schema that introduces all the dimensions that are going to be taken in consideration in this data modelling for the data mart of an Airline Comany.
  • 7. Normalization Database normalization is a technique of organizing the data in the database. Normalization is a formal approach that applies a set of rules to associate attributes with entities. Normalization is used when designing a database. (datanamic.com, n.d.) Normalization is a data design process that has a high level goal of keeping each fact in just one place to avoid data redundancy and insert, update, and delete anomalies. (oracle.com, n.d.) Data model after Normalization: Figure.3.Entity Relationship Schema
  • 8. Star Schema and introduction of dimensions The term star schema is a way of referring to a "dimensional modeling" approach to defining your data model. Most descriptions of dimensional modeling use terminology drawn from the work of Ralph Kimball, the pioneering consultant and writer in this field. Dimensional modeling creates multiple star schemas, each based on a business process such as sales or marketing. Star schemas divide data into facts and dimensions. Facts are the measurements of some event such as a sale and are typically numbers. Dimensions are the categories you use to identify facts, such as date, location, and product. (oracle.com, n.d.) In the figure below there is the star schema of our database: Figure.4: Star Schema In our example there are 3 dimensions: Customer, Agent and Time Dimension.  Customer describes each customer based on their attributes identified by customer_ ID.  Agent describes each agent of this company identified by agent_ ID.  Time is the time of the flights. The fact refers to every dimension. The association between the fact and the dimension is always one to any, which means each fact is associated with exactly one unit of the single dimension, and each unit of the dimension can be associated with any number of facts (including 0). (Gornik, n.d.) The dimension Agent will have three levels and one hierarchy:  Total  Agency  Agent
  • 9. The attributes for agent dimension are:  agent fullname(firstname+lastname)  agentid  sourceid Also, the dimension Customer will have three levels and one hierarchy:  Total  Age  Customer The attributes for agency dimension:  agencyid  sourceid The dimension Time will have three levels and one hierarchy:  Total  Year  Month Attributes for the year:  Year Attributes for the month:  Month name  Description  Quarter Measures that going to be part are:  Total amount  Number of tickets sold
  • 10. Overview ofQuery In the first chapter we describe both the physical design and logical design of our data warehouse. In this chapter we are going to describe and show all the query needed to perform different actions until we will implement the whole data warehouse for our Airline Company. CREATE USERS… CREATE TABLES… SELECT… INSERT… etc. Queries for creating tables of our first database AD. First of all we are going to create a user named ad. The commands used in CMD are: SQL> CREATE USER ad IDENTIFIED BY ad; User created. SQL> GRANT Create Session TO ad; Then, we create a new connection, and after this we start by creating tables: Queries used for this are: CREATE TABLE ad.Agency ( AgencyId number NOT NULL PRIMARY KEY, -- primary key column City varchar2(50) NOT NULL, NoOfAgents number NOT NULL ); For populating the Agency table write the INSERT statement. For example: INSERT INTO ad.Agency (AgencyId, City, NoOfAgents) VALUES (1,'Tirana', 3);
  • 11. The result after SELECT * from ad.Agency; is: The second table of this database is Agent: CREATE TABLE ad.Agent ( AgentId number NOT NULL PRIMARY KEY, -- primary key column AgencyId number NOT NULL, AgentName varchar2(50) NOT NULL, AgentSurname varchar2(50) NOT NULL, CONSTRAINT FK_AgentWorks FOREIGN KEY (AgencyId ) REFERENCES ad.Agency(AgencyId)); The first instance: INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname) VALUES (1, 1,'John', 'Miller'); INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname) VALUES (2, 1,'Keith','Armstrong'); INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname) VALUES (3, 1,'Donna','Anderson'); INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname) VALUES (4, 2,'Janet','Bell'); INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname)
  • 12. VALUES (5, 2,'Rose','Saunders'); INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname) VALUES (6, 2,'Scott','Simpson'); INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname) VALUES (7, 3,'Steve','Thompson'); INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname) VALUES (8, 3,'Sam','White'); INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname) VALUES (9, 3,'Sam','White'); INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname) VALUES (10, 4,'Maria','Adams'); INSERT INTO ad.Agent (AgentId, AgencyId, AgentName, AgentSurname) VALUES (11, 4,'Lili','Allen'); The next step is creating the other user TOD, that is going to use as a source database too. create user tod identified by tod; grant create session to tod; grant resource to tod; alter user tod default role resource;
  • 13. Queries for creating tables of our first database TOD. After this, just like we did for the first database, we now can create the third tables of the second database. CREATE TABLE tod.customer ( CustomerId number NOT NULL PRIMARY KEY, -- primary key column agencyid number NOT NULL, CustomerName varchar2(50) NOT NULL, CustomerSurbame varchar2(50) NOT NULL, Age number NOT NULL, PhoneNumber number NOT NULL); CREATE TABLE tod.BookingDetails ( BookingId number NOT NULL PRIMARY KEY, -- primary key column TicketId number NOT NULL, AgentId number NOT NULL, OriginCountry varchar2(50) NOT NULL, DestinationCountry varchar2(50) NOT NULL, CONSTRAINT FK_Booking_Ticket FOREIGN KEY (TicketId) REFERENCES tod.Ticket(TicketId));
  • 14. CREATE TABLE tod.Ticket ( TicketId number NOT NULL PRIMARY KEY, -- primary key column AgentId number NOT NULL, CustomerId number NOT NULL, Price number NOT NULL, TicketType varchar2(50) NOT NULL, CONSTRAINT FK_Cust_Ticket FOREIGN KEY (CustomerId) REFERENCES tod.Customer(CustomerId) ); After creating these tables, it should be displayed the below result:
  • 15. And the INSERT statement for the tables BOOKING DETAILS, TICKET and CUSTOMER is as follows: INSERT INTO tod.customer VALUES (101, 1,'Dave','Smith', 24, 35569878); INSERT INTO tod.customer VALUES (102, 1,'Ivan','Brown', 30, 35569585); INSERT INTO tod.customer VALUES (103, 2,'Ramon','King', 23, 35421412); INSERT INTO tod.customer VALUES (104, 2,'Ester','Moore', 44, 3521352); INSERT INTO tod.customer VALUES (105, 4,'Jorge','Lopez', 45, 35252512); INSERT INTO tod.customer VALUES (106, 3,'Roberto','Miller', 35, 3522511); INSERT INTO tod.customer VALUES (107, 5,'Nathaniel','Wilson', 55, 35263611); INSERT INTO tod.customer VALUES (108, 6,'Claude','Hill', 51, 352652511); INSERT INTO tod.customer VALUES (109, 6,'Ethan','Taylor', 31, 352652513); INSERT INTO tod.customer VALUES (110, 7,'Lewis','Jackson', 31, 3526587813); INSERT INTO tod.customer VALUES (111, 7,'Glen','Nelson', 29, 3526587813); INSERT INTO tod.customer VALUES (112, 8,'Joshua','Thomas',59, 38887813); INSERT INTO tod.customer VALUES (113, 9,'Peter','Harris', 39, 38855513); INSERT INTO tod.customer VALUES (114, 10,'Shane','Cooper', 20, 388544443); INSERT INTO tod.customer VALUES (115, 11,'Aaron','Mitchell', 35, 35555443); COMMIT; Write: select * from tod.customer;
  • 16. The population of the second table: INSERT INTO tod.Ticket VALUES (1, 1, 101, 35,'General admission'); INSERT INTO tod.Ticket VALUES (2, 1, 102, 55,'General admission'); INSERT INTO tod.Ticket VALUES (3, 1, 101, 105,'VIP'); INSERT INTO tod.Ticket VALUES (4, 2, 103, 111,'General admission'); INSERT INTO tod.Ticket VALUES (5, 2, 101, 222,'VIP'); INSERT INTO tod.Ticket VALUES (6, 3, 104, 202,'General admission'); INSERT INTO tod.Ticket VALUES (7, 4, 105, 41,'General admission'); INSERT INTO tod.Ticket VALUES (8, 6, 106, 102,'General admission'); INSERT INTO tod.Ticket VALUES (9, 7, 106, 23,'General admission'); INSERT INTO tod.Ticket VALUES (10, 7, 106, 255,'VIP'); INSERT INTO tod.Ticket VALUES (11, 8, 107, 95,'General admission'); INSERT INTO tod.Ticket VALUES (12, 8, 101, 105,'General admission'); INSERT INTO tod.Ticket VALUES (13, 9, 108, 75,'General admission'); INSERT INTO tod.Ticket VALUES (14, 9, 109, 35,'General admission'); INSERT INTO tod.Ticket VALUES (15, 10, 111, 35,'General admission'); INSERT INTO tod.Ticket VALUES (16, 11, 110, 55,'General admission'); INSERT INTO tod.Ticket VALUES (17, 11, 114, 102,'General admission'); INSERT INTO tod.Ticket VALUES (18, 11, 115, 52,'General admission'); INSERT INTO tod.Ticket VALUES (19, 9, 113, 111,'VIP');
  • 17. INSERT INTO tod.Ticket VALUES (20, 11, 112, 101,'General admission'); COMMIT; Write: Select * from tod.Ticket;
  • 18. The population of the third table: INSERT INTO tod.BookingDetails VALUES (10, 1, 1,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (11, 2, 2,'Italy','Albania'); INSERT INTO tod.BookingDetails VALUES (12, 3, 3,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (13, 4, 4,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (14, 5, 5,'Italy','Albania'); INSERT INTO tod.BookingDetails VALUES (15, 6, 6,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (16, 7, 7,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (17, 7, 7,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (18, 8, 8,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (19, 9, 9,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (20, 10, 10,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (21, 11, 11,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (22, 12, 1,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (23, 13, 2,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (24, 14, 3,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (26, 15, 4,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (27, 16, 5,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (28, 17, 6,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (29, 18, 7,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (29, 18, 7,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (29, 19, 8,'Albania','Italy'); INSERT INTO tod.BookingDetails VALUES (30, 20, 9,'Italy','Albania'); COMMIT;
  • 19. Write: select * from tod.BookingDetails; Once we have created the tables as sysdba, we create user dataw, in order to use as our data warehouse. create user dataw identified by dataw default tablespace USERS temporary tablespace USERS account unlock; grant create session to dataw; grant resource to dataw; alter user dataw default role resource;
  • 20. As we did for the first databases, as user dataw we have to create tables based on dimensions we have determined. Two tables we are going to use are table agent and table customer, and fact_table. CREATE TABLE agent( id number(6,0) PRIMARY KEY, id_total number(6,0), total varchar2(30), idagency number (6,0), agencySourceId number (6,0), agentid number (6,0), fullname varchar2(46), agent_source_id number (6,0) ) CREATE TABLE customer( id number(6,0) PRIMARY KEY, id_total number(6,0), total varchar2(30), avg_age number (6,0), custid number (6,0), cust_fullname varchar2(46), cust_source_id number (6,0) ) select * from dataw.agent; select * from dataw.customer;
  • 21. Fact table: CREATE TABLE fact_table( time_id number(6, 0), agent_id number(6, 0), customer_id number(6,0), amount NUMBER(8,2), no_tickets number(6,0), CONSTRAINT "agent_id_FK" FOREIGN KEY (agent_id) REFERENCES dataw.agent(id), CONSTRAINT "customer_id_FK" FOREIGN KEY (customer_id) REFERENCES dataw.customer(id), CONSTRAINT "pk" PRIMARY KEY (agent_id, customer_id,time_id)); Write: select * from dataw.fact_table; we can see all the attributes added in fact_table:
  • 22. In order to have access in two source databases, we should grant access to the target schema as sysdba: grant select on ad.agent to dataw; grant select on ad.agency to dataw; grant select on tod.BookingDetails to dataw; grant select on tod.customer to dataw; grant select on tod.ticket to dataw; The CREATE SEQUENCE statement allows you to create a new sequence in the database. Create the sequence for the dimension agent. create sequence seq_agent start with 1 increment by 1; Create the sequence for the dimension customer. create sequence seq_cust start with 1 increment by 1; Next step is to fill the two tables we created on dataw, with values: insert into agent (id, total) values ( seq_agent.nextval,'All agents'); update agent set id_total=id;
  • 23. Write: select * from dataw.agent; Once we have created the two tables in dataw schema, now we have to insert the values. The values will be taken from our two source databases AD and TOD. We have determined the Agent dimension with three levels: Total, Agency and Agent. The population of data warehouse will become by filling one by one the dimensions: 1) Fill the agency level As sysdba grant access to the target schema to select the source tables: grant select on ad.agency to dataw; Now we can write INSERT statement: insert into agent(id,id_total, total, agencySourceId ) select seq_agent.nextval, a.id_total, a.total, AgencyId as agencySourceId from ad.agency cross join agent a; update agent set idagency=id where agencySourceId is not null; Write: select * from dataw.agent;
  • 24. 2) Fill the agent level: insert into agent (id, id_total, total,idagency , agencySourceId , fullname,agent_source_id) select seq_agent.nextval, a.id_total, a.total, a.idagency, a.agencySourceId, source.AgentName || ' ' || source.AgentSurname as fullname, source.AgentId as source_id from ad.Agent source join agent a on source.AgencyId=a.agencySourceId; 3) Insert values in Customer Table 3.1) Fill the TOTAL level insert into customer (id, total) values ( seq_cust.nextval,'All customers'); update customer set id_total=id; Write: select * from customer;
  • 25. In customer table, we are going to made a change. A new attribute age_source_id will be added, by using ALTER statement: ALTER TABLE customer ADD age_source_id number; 3.2) Fill the age level: insert into customer(id, id_total, total, avg_age, age_source_id) select seq_cust.nextval as id, c.id_total, c.total,source.age, source.customerid from tod.customer source cross join customer c; 3.3) Fill the customer level: insert into customer(id, id_total, total, avg_age, age_source_id,cust_fullname, cust_source_id) select seq_cust.nextval as id, target.id_total, target.total, target.avg_age, target.age_source_id, source.customername || ' '|| source.customersurbame as fullname, source.CustomerId as cust_source_id
  • 26. from tod.customer source join customer target on source.CustomerId =target.age_source_id; update customer set custid =id where cust_source_id is not null;
  • 27. The last dimension that is needed to take into consideration is TIME DIMENSION. Let’s start with creation of tables one by one: create table TIME( id number(6,0) primary key, id_total number(6,0), total varchar2(20), id_year number(6,0), year number(4), id_month number(6,0), month number(2), description varchar2(20), quarter number(1) ) As we did for the other tables, the next step is to create the time sequence: create sequence time_seq start with 1 increment by 1; 1) Fill the total level insert into TIME (id,total) values (TIME_SEQ.nextval,'All years'); update time set id_total=id; 2) Create the procedure to insert records for the years create or replace PROCEDURE add_years ( first_year number, second_year number ) IS
  • 28. y number; BEGIN y:=first_year; while (y <=second_year) loop insert into time (id,id_total, total, year) select time_seq.nextval,id_total, total,y from time where year is null; y:=y+1; end loop; END add_years; 3) EXECUTE the procedure add_years exec add_years(2001,2010); update time set id_year=id where year is not null; 4) Insert the records for the months insert into time(id, id_total, total, id_year, year,month, description, quarter ) select time_seq.nextval , t.id_total, t.total, t.id_year, t.year, months.month, months.descr, months.quarter from time t cross join ( select 1 month, 'Jan' Descr, 1 Quarter from dual union select 2 month, 'Feb' Descr, 1 Quarter from dual union
  • 29. select 3 month, 'Mar' Descr, 1 Quarter from dual union select 4 month, 'Apr' Descr, 2 Quarter from dual union select 5 month, 'May' Descr, 2 Quarter from dual union select 6 month, 'Jun' Descr, 2 Quarter from dual union select 7 month, 'Jul' Descr, 3 Quarter from dual union select 8 month, 'Aug' Descr, 3 Quarter from dual union select 9 month, 'Sep' Descr, 3 Quarter from dual union select 10 month, 'Oct' Descr, 4 Quarter from dual union select 11 month, 'Nov' Descr, 4 Quarter from dual union select 12 month, 'Dec' Descr, 4 Quarter from dual ) months where t.id_year is not null; update time set id_month=id where month is not null;
  • 30. Fact_Table is the last table, we are going to INSERT values. One last thing except dimensions are measures Total amount and number of tickets sold. In order to determine time dimension, it is needed to add another attribute ticket_date, in Ticket table, in the second database TOD. alter table ticket add ticket_date number(10); Let’s update the new column: update tod.ticket set ticket_date = 10112019 where TicketId =1; update tod.ticket set ticket_date = 10122019 where TicketId =2; update tod.ticket set ticket_date = 11112019 where TicketId =3; update tod.ticket set ticket_date = 12112019 where TicketId =4; update tod.ticket set ticket_date = 13112019 where TicketId =5; update tod.ticket set ticket_date = 14112019 where TicketId =6; update tod.ticket set ticket_date = 15112019 where TicketId =7; update tod.ticket set ticket_date = 16112019 where TicketId =8; update tod.ticket set ticket_date = 17112019 where TicketId =9; update tod.ticket set ticket_date = 21112019 where TicketId =10; update tod.ticket set ticket_date = 22112019 where TicketId =11; update tod.ticket set ticket_date = 23112019 where TicketId =12; update tod.ticket set ticket_date = 24112019 where TicketId =13; update tod.ticket set ticket_date = 24122019 where TicketId =14; update tod.ticket set ticket_date = 25112019 where TicketId =15; update tod.ticket set ticket_date = 26112019 where TicketId =16; update tod.ticket set ticket_date = 27112019 where TicketId =17; update tod.ticket set ticket_date = 28112019 where TicketId =18; update tod.ticket set ticket_date = 29112019 where TicketId =19; update tod.ticket set ticket_date = 30112019 where TicketId =20;
  • 31. Now, we have to INSERT values in fact_table. insert into fact_table (agent_id, customer_id,time_id, amount,no_tickets) select t.id, a.id, c.id, sum(source.price) as amount, count(source.TicketId) as no_tickets from tod.ticket source join customer c on source.CustomerId=c.cust_source_id join agent a on source.TicketId=a.AgentId join time t on (to_char(ticket_date,'yyyy')=t.year and to_char(ticket_date,'mm')=t.month) group by t.id,a.id, c.id order by t.id,a.id, c.id;
  • 32. RAPORTS Below are some raports based on information above that we inserted in our data warehouse user: 1)Suppose we want the amount based on price of ticket sold per each agent and per each agent we need fullname and agent id. In dataw, write the below query: select agent_id,fullname,amount form fact_table join agent on fact_table.agent_id=agent.agentid; 2)The second would be the number of tickets that each customer has bought in this company: Select customer_id,no_tickets from fact_table join customer on fact_table.customer_id=customer.custid; 3)All the tickets sold in December Select no_ticket,time from fact_table where time between ‘01122019’ and ‘31122019’; 4)Average age of customers Select custid,cust_fullname, sum(avg_age)/2 as ‘avarage age’ from customer; 5)Number of tickets sold per each agency. Select id_agency,no_tickets from fact_table join agent on fact_table.agent_id=agent.agentid;
  • 33. References datanamic.com. (n.d.). https://www.datanamic.com/support/database-normalization.html. Retrieved from https://www.datanamic.com/support/database-normalization.html. Gornik, D. (n.d.). https://www.techwell.com/sites/default/files/articles/XUS2170853file1_0.pdf. Retrieved from https://www.techwell.com/sites/default/files/articles/XUS2170853file1_0.pdf. oracle.com.(n.d.). https://docs.oracle.com/database/121/DWHSG/E41670-11.pdf.Retrievedfrom https://docs.oracle.com/database/121/DWHSG/E41670-11.pdf: https://docs.oracle.com/database/121/DWHSG/E41670-11.pdf