Sunteți pe pagina 1din 15

MANAJEMEN BASIS DATA – IS184621

PROYEK KELOMPOK – CHAPTER 12

Star Schema, Dummy Data, dan Menjawab Pertanyaan Bisnis

Disusun Oleh:
Kelompok 4
Alvian Eka Maulana 05211640000047
Dani Hadi Saputro 05211640000068
Muslikh Annur Meiviananda 05211640000092
Fathoni Nur Muhammad 05211640000093
Ahmad Naufal Rofif 05211640000113

Dosen Pengampu:
Rully Agus Hendrawan, S. Kom, M. Sc

Departemen Sistem Informasi


Fakultas Teknologi Informasi dan Komunikasi
1
DAFTAR ISI

1. MEMBUAT LOGICAL DATA MODEL ............................................................................1


LOGICAL DATA MODEL CUSTOMER_SALES FACT ....................................................................................................................... 1
LOGICAL DATA MODEL CUSTOMER_INVOICES FACT ................................................................................................................... 1
LOGICAL DATA MODEL CUSTOMER_REP_SALES FACT ............................................................................................................... 2
LOGICAL DATA MODEL PRODUCT_SALES FACT .......................................................................................................................... 2
GABUNGAN DARI SEMUA STAR SCHEMA..................................................................................................................................... 3

2. MENGISIKAN CONTOH DATA .....................................................................................3


TABEL ADDRESSES ...................................................................................................................................................................... 3
TABEL CUSTOMER_DEMOGRAPHICS ............................................................................................................................................. 3
TABEL CUSTOMER_INVOICES ....................................................................................................................................................... 3
TABEL CUSTOMER_REP_SALES .................................................................................................................................................... 4
TABEL CUSTOMER_SALES ............................................................................................................................................................ 4
TABEL CUSTOMERS ..................................................................................................................................................................... 4
TABEL GEOGRAPHIC_BOUNDARIES .............................................................................................................................................. 4
TABEL INTERNAL_ORGANIZATIONS ............................................................................................................................................. 4
TABEL PRODUCT_SALES .............................................................................................................................................................. 4
TABEL PRODUCT ......................................................................................................................................................................... 5
TABEL SALES_REPS ..................................................................................................................................................................... 5
TABEL TIME_BY_DAY ................................................................................................................................................................. 5
TABEL TIME_BY_MONTH ............................................................................................................................................................. 5

3. MENJAWAB PERTANYAAN BISNIS ..............................................................................5


WHAT WAS THE SALES VOLUME FOR A PRODUCT DURING A SPECIFIC TIME PERIOD? ...................................................................... 5
WHAT WAS THE SALES VOLUME FOR A CATEGORY OF PRODUCTS FOR A SPECIFIC TIME PERIOD? .................................................... 6
HOW MUCH OF EACH PRODUCT DID VARIOUS CUSTOMERS BUY? ................................................................................................... 6
HOW MUCH OF EACH PRODUCT CATEGORY DID A SELECTED CUSTOMER BUY? ............................................................................... 7
HOW MUCH ARE THE SALES REPS SELLING? TO WHOM ARE THEY SELLING? ................................................................................... 7
WHICH PRODUCTS OR PRODUCT CATEGORIES ARE THEY SELLING? ................................................................................................ 8
WHEN WERE SALES THE BEST? WHEN WERE SALES THE WORST? .................................................................................................. 8
DURING THOSE TIMES WHO WAS BUYING AND WHO WAS MAKING THE SALE? ................................................................................ 8
WHICH PRODUCTS AND/OR CUSTOMERS ARE MOST PROFITABLE?.................................................................................................. 9
WHAT WAS THE SALES REVENUE FROM A SPECIFIC PRODUCT OVER THE LAST 12 MONTHS? ........................................................... 9
WHAT WAS THE HIGHEST VOLUME OF A PRODUCT FOR A SPECIFIC MONTH?................................................................................. 10
WHICH PRODUCT HAD THE GREATEST REVENUE ACROSS ALL SALES? ......................................................................................... 10
WITHIN THAT PRODUCT, WHICH GEOGRAPHIC REGION HAD THE GREATEST REVENUE? ................................................................ 10
WHAT WAS THE PROFITABILITY FOR EACH PRODUCT OR PRODUCT CATEGORY IN A CERTAIN COUNTRY FOR SPECIFIC YEAR? ........ 11
WHICH COUNTRY HAS GENERATED THE GREATEST AVERAGE ANNUAL REVENUE BY PRODUCT? ................................................... 11
WHAT WAS THE SALES VOLUME FOR A SPECIFIC SALES REP OVER THE LAST 12 MONTHS? ............................................................ 12
WHICH CUSTOMER BOUGHT THE HIGHEST VOLUME THROUGH A PARTICULAR SALES REP FOR A SPECIFIC MONTH? ....................... 12
WHAT WAS THE DISTRIBUTION OF SALES ACROSS A SALES REP'S CUSTOMERS? ............................................................................ 12
HOW MUCH DOES EACH SALES REP SELL ACROSS EACH OF HIS OR HER ASSIGNED STATES? .......................................................... 13
WITHIN EACH STATE, WHICH CITY HAD THE GREATEST VOLUME FOR A SALES REP? ..................................................................... 13

2
1. Membuat Logical Data Model
Berikut adalah Star Schema Kami:

 Logical Data Model Customer_Sales Fact

 Logical Data Model Customer_Invoices Fact

1
 Logical Data Model Customer_Rep_Sales Fact

 Logical Data Model Product_Sales Fact

2
 Gabungan Dari Semua Star Schema

2. Mengisikan Contoh Data


Berikut adalah Tampilan Contoh Data yang memuat Atribut dan Value dari Atribut di Setiap
Row. Karena beberapa tabel memiliki banyak data Dummy (Lebih dari 10 Row), untuk tabel
tersebut kami hanya akan menampilkan 10 row pertama dari tiap Tabel.

 Tabel addresses

 Tabel customer_demographics

 Tabel customer_invoices

3
 Tabel customer_rep_sales

 Tabel customer_sales

 Tabel customers

 Tabel geographic_boundaries

 Tabel internal_organizations

 Tabel product_sales

4
 Tabel product

 Tabel sales_reps

 Tabel time_by_day

 Tabel time_by_month

3. Menjawab Pertanyaan Bisnis


 What was the sales volume for a product during a specific time period?
Query:
SELECT product_sales.product_id,
product_sales.quantity,
time_by_month.fiscal_year,
time_by_month.month,
time_by_month.quarter,
products.product_description
FROM product_sales
JOIN products ON product_sales.product_id = products.product_id
JOIN time_by_month ON product_sales.month_id = time_by_month.month_id;

5
View:

 What was the sales volume for a category of products for a specific time period?
Query:
SELECT product_sales.product_id,
product_sales.quantity,
time_by_month.fiscal_year,
time_by_month.month,
time_by_month.quarter,
products.category_description
FROM product_sales
JOIN products ON product_sales.product_id = products.product_id
JOIN time_by_month ON product_sales.month_id = time_by_month.month_id;
View:

 How much of each product did various customers buy?


Query:
SELECT customer_sales.product_id,
customer_sales.quantity,
products.product_description,
customers.customer_name
FROM customer_sales
JOIN customers ON customer_sales.customer_id = customers.customer_id
JOIN products ON customer_sales.product_id = products.product_id;
View:

6
 How much of each product category did a selected customer buy?
Query:
SELECT customer_sales.product_id,
customer_sales.quantity,
products.category_description,
customers.customer_name
FROM customer_sales
JOIN customers ON customer_sales.customer_id = customers.customer_id
JOIN products ON customer_sales.product_id = products.product_id;
View:

 How much are the sales reps selling? To whom are they selling?
Query:
SELECT DISTINCT sales_reps.manager_last_name,
sales_reps.manager_first_name,
sales_reps.sales_rep_last_name,
sales_reps.sales_rep_first_name,
customer_sales.product_id,
customer_sales.quantity,
products.product_description,
customers.customer_name
FROM customer_sales
JOIN customers ON customer_sales.customer_id = customers.customer_id
JOIN products ON customer_sales.product_id = products.product_id
JOIN sales_reps ON customer_sales.sales_reps_id = sales_reps.sales_reps_id
JOIN sales_reps alias_ppa_1556729891 ON customer_sales.manager_rep_id =
sales_reps.manager_rep_id;
View:

7
 Which products or product categories are they selling?
Query:
SELECT DISTINCT sales_reps.sales_rep_last_name,
sales_reps.sales_rep_first_name,
customer_sales.product_id,
customer_sales.quantity,
products.category_description,
customers.customer_name
FROM customer_sales
JOIN customers ON customer_sales.customer_id = customers.customer_id
JOIN products ON customer_sales.product_id = products.product_id
JOIN sales_reps ON customer_sales.sales_reps_id = sales_reps.sales_reps_id
JOIN sales_reps alias_ppa_1556730192 ON customer_sales.manager_rep_id =
sales_reps.manager_rep_id;
View:

 When were sales the best? When were sales the worst?
Query:
SELECT time_by_day.fiscal_year,
count(time_by_day.fiscal_year) AS count
FROM time_by_day
GROUP BY time_by_day.fiscal_year;
View:

 During those times who was buying and who was making the sale?
Query:
SELECT DISTINCT sales_reps.manager_last_name,
sales_reps.manager_first_name,
sales_reps.sales_rep_last_name,
sales_reps.sales_rep_first_name,
customer_sales.product_id,
customer_sales.quantity,
products.product_description,
customers.customer_name
8
FROM customer_sales
JOIN customers ON customer_sales.customer_id = customers.customer_id
JOIN products ON customer_sales.product_id = products.product_id
JOIN sales_reps ON customer_sales.sales_reps_id = sales_reps.sales_reps_id
JOIN sales_reps alias_ppa_1556729891 ON customer_sales.manager_rep_id =
sales_reps.manager_rep_id;
View:

 Which products and/or customers are most profitable?


Query:
SELECT customers.customer_name,
customer_sales.quantity,
customer_sales.gross_sales,
customer_sales.product_cost
FROM customers
JOIN customer_sales ON customers.customer_id = customer_sales.customer_id
ORDER BY customer_sales.gross_sales DESC;
View:

 What was the sales revenue from a specific product over the last 12 months?
Query:
SELECT time_by_day.fiscal_year,
time_by_day.month,
customer_sales.gross_sales,
customer_sales.day_id,
products.product_description
FROM customer_sales
JOIN time_by_day ON customer_sales.day_id = time_by_day.day_id
JOIN products ON customer_sales.product_id = products.product_id
WHERE time_by_day.fiscal_year >= '2018'::numeric OR time_by_day.month >=
'4'::smallint;
View:

9
 What was the highest volume of a product for a specific month?
Query:
SELECT product_sales.product_id,
product_sales.quantity,
time_by_month.fiscal_year,
time_by_month.month,
products.product_description
FROM product_sales
JOIN products ON product_sales.product_id = products.product_id
JOIN time_by_month ON product_sales.month_id = time_by_month.month_id
WHERE product_sales.quantity = 4::numeric;
View:

 Which product had the greatest revenue across all sales?


Query:
SELECT time_by_day.fiscal_year,
time_by_day.month,
customer_sales.gross_sales,
customer_sales.quantity,
products.product_description
FROM customer_sales
JOIN time_by_day ON customer_sales.day_id = time_by_day.day_id
JOIN products ON customer_sales.product_id = products.product_id
WHERE customer_sales.gross_sales = 28600::numeric;
View:

 Within that product, which geographic region had the greatest revenue?
Query:
SELECT product_sales.product_id,
product_sales.gross_sales,

10
geographic_boundaries.state_name,
geographic_boundaries.city_name,
products.product_description
FROM product_sales
JOIN products ON product_sales.product_id = products.product_id
JOIN geographic_boundaries ON product_sales.geo_id = geographic_boundaries.geo_id
WHERE geographic_boundaries.city_name::text = 'Surabaya'::text;
View:

 What was the profitability for each product or product category in a certain country for
specific year?
Query:
SELECT products.product_id,
products.product_description,
product_sales.gross_sales - product_sales.product_cost AS profit,
time_by_month.fiscal_year,
geographic_boundaries.country_name
FROM products
JOIN product_sales ON products.product_id = product_sales.product_id
JOIN time_by_month ON product_sales.month_id = time_by_month.month_id
JOIN geographic_boundaries ON product_sales.geo_id = geographic_boundaries.geo_id;
View:

 Which country has generated the greatest average annual revenue by product?
Query:
SELECT geographic_boundaries.country_name,
sum(product_sales.gross_sales) AS total_revenue,
time_by_month.fiscal_year
FROM geographic_boundaries
JOIN product_sales ON geographic_boundaries.geo_id = product_sales.geo_id
JOIN time_by_month ON product_sales.month_id = time_by_month.month_id
GROUP BY geographic_boundaries.country_name, time_by_month.fiscal_year;
View:
11
 What was the sales volume for a specific sales rep over the last 12 months?
Query:
SELECT
sales_reps.sales_rep_first_name,
sales_reps.sales_rep_last_name,
SUM(customer_invoices.gross_sales) as sales_volume
FROM customer_invoices
JOIN sales_reps ON customer_invoices.sales_reps_id = sales_reps.sales_reps_id
JOIN time_by_day ON customer_invoices.day_id = time_by_day.day_id
WHERE time_by_day.fiscal_year >= 2018 AND sales_reps.sales_reps_id = 1
GROUP BY sales_reps. sales_rep_last_name, sales_reps.sales_rep_first_name
View:

 Which customer bought the highest volume through a particular sales rep for a specific
month?
Query:
SELECT
customers.customer_name,
SUM(customer_invoices.gross_sales) as sales_volume,
time_by_day. Month,
sales_reps.sales_rep_first_name,
sales_reps.sales_rep_last_name
FROM customer_invoices
JOIN sales_reps ON customer_invoices.sales_reps_id = sales_reps.sales_reps_id
JOIN customers ON customers.customer_id = customer_invoices.customer_id
JOIN time_by_day ON customer_invoices.day_id = time_by_day.day_id
WHERE time_by_day. month = 12 AND sales_reps.sales_reps_id = 5
GROUP BY customers.customer_name, time_by_day. Month,
sales_reps.sales_rep_first_name, sales_reps.sales_rep_last_name
View:

 What was the distribution of sales across a sales rep's customers?


Query:
Insert here

12
View:

 How much does each sales rep sell across each of his or her assigned states?
Query:
SELECT sales_reps.sales_rep_first_name,
sales_reps.sales_rep_last_name,
SUM(customer_invoices.gross_sales) as sales_volume,
addresses.city_name
FROM customer_invoices
JOIN addresses ON addresses.address_id = customer_invoices.address_id
JOIN sales_reps ON customer_invoices.sales_reps_id = sales_reps.sales_reps_id
GROUP BY addresses.city_name, sales_reps.sales_rep_first_name,
sales_reps.sales_rep_last_name
View:

 Within each state, which city had the greatest volume for a sales rep?
Query:
SELECT addresses.country_name,
addresses.city_name,
sales_reps.sales_rep_first_name,
sales_reps.sales_rep_last_name,
customer_invoices.gross_sales as sales_volume

FROM customer_invoices
JOIN addresses ON addresses.address_id = customer_invoices.address_id
JOIN sales_reps ON customer_invoices.sales_reps_id = sales_reps.sales_reps_id
WHERE sales_reps.sales_reps_id = 5
ORDER BY sales_volume DESC
View:

13

S-ar putea să vă placă și