You are on page 1of 10

Table Creation:

CREATE TABLE `dimaddress` (


`address_key` int NOT NULL,
`building_no` int DEFAULT NULL,
`room_no` int DEFAULT NULL,
`pincode` int DEFAULT NULL,
PRIMARY KEY (`address_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `dimcustomer` (
`cust_id` int NOT NULL,
`first_name` varchar(50) DEFAULT NULL,
`last_name` varchar(50) DEFAULT NULL,
`email_add` varchar(50) DEFAULT NULL,
`start_date` date DEFAULT NULL,
`end_date` date DEFAULT NULL,
`dim_cust_type` int DEFAULT NULL,
`address_id` int DEFAULT NULL,
PRIMARY KEY (`cust_id`),
FOREIGN KEY (`address_id`)
REFERENCES `dimaddress` (`address_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `dimdate` (
`date_key` int NOT NULL,
`date_of_the_day` date DEFAULT NULL,
`day_name` varchar(10) DEFAULT NULL,
`month_name` varchar(10) DEFAULT NULL,
`month_no` int DEFAULT NULL,
`year_transaction` int DEFAULT NULL,
PRIMARY KEY (`date_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `dimwallet` (
`wallet_id` int NOT NULL,
`wallet_type` varchar(28) DEFAULT NULL,
`start_date` date DEFAULT NULL,
`expiry_date` date DEFAULT NULL,
`wallet_price` int DEFAULT NULL,
PRIMARY KEY (`wallet_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `factspecific` (
`specific_id` int NOT NULL,
`credit` int DEFAULT NULL,
`debit` int DEFAULT NULL,
`address_key` int DEFAULT NULL,
`cust_id` int DEFAULT NULL,
PRIMARY KEY (`specific_id`),
FOREIGN KEY (`address_key`) REFERENCES `dimaddress` (`address_key`),
FOREIGN KEY (`cust_id`) REFERENCES `dimcustomer` (`cust_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `factwallet` (
`transaction_id` int NOT NULL,
`transaction_date` int DEFAULT NULL,
`cust_id` int DEFAULT NULL,
`wallet_id` int DEFAULT NULL,
`wallet_type` varchar(20) DEFAULT NULL,
`total_credit` int DEFAULT NULL,
`total_debit` int DEFAULT NULL,
PRIMARY KEY (`transaction_id`),
FOREIGN KEY (`transaction_date`) REFERENCES `dimdate` (`date_key`),
FOREIGN KEY (`cust_id`) REFERENCES `dimcustomer` (`cust_id`),
FOREIGN KEY (`wallet_id`) REFERENCES `dimwallet` (`wallet_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
QUERIES:
QUERY 1.
QUERY 2.
QUERY 3.

You might also like