-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsafaricom_db&table_creation.sql
More file actions
35 lines (32 loc) · 1.02 KB
/
safaricom_db&table_creation.sql
File metadata and controls
35 lines (32 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-- Create the database
CREATE DATABASE safaricom_ra;
USE safaricom_ra;
-- Create the Tariff Reference Table (Static lookup)
CREATE TABLE tariff_reference (
rate_plan_id VARCHAR(50) PRIMARY KEY,
Voice_Rate DECIMAL(10, 4),
Data_Rate DECIMAL(10, 5),
SMS_Rate DECIMAL(10, 4)
);
-- Create the CDR Table (Source of Truth / Actual Usage)
CREATE TABLE cdr_data (
cdr_id VARCHAR(50) PRIMARY KEY,
timestamp DATETIME,
msisdn_a VARCHAR(30), -- FIX: Increased length for complex numbers
service_type VARCHAR(10),
charging_element_id VARCHAR(50),
rate_plan_id VARCHAR(50),
duration_volume INT,
true_charge DECIMAL(10, 4)
);
-- Create the Billing Table (Reported Revenue)
CREATE TABLE billing_data (
cdr_id VARCHAR(50) PRIMARY KEY,
timestamp DATETIME,
msisdn_a VARCHAR(30), -- FIX: Increased length for complex numbers
service_type VARCHAR(10),
charging_element_id VARCHAR(50),
rate_plan_id VARCHAR(50),
duration_volume INT,
billed_charge DECIMAL(10, 4)
);