The system is a hotel management software with multiple hotels attached to it. The schema is as follows:
CREATE TABLE `ms_property` (
`id` int(10) NOT NULL,
`name` varchar(254) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `ms_property` (`id`, `name`) VALUES(1, 'Black Forest');
CREATE TABLE `ms_property_room` ( `id` int(10) NOT NULL, `property_id` int(10) NOT NULL,
`room_name` varchar(254) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `ms_property_room` (`id`, `property_id`, `room_name`) VALUES (1, 1, 'Standard Room'),
(2, 1, 'AC Room');
CREATE TABLE `ms_tariff_type` (
`tt_id` bigint(20) NOT NULL,
`tt_tariff_name` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `ms_tariff_type` (`tt_id`,`tt_tariff_name`) VALUES
(1, 'Season Rates'),
(2, 'Contracted Rates');
CREATE TABLE `room_tariff` (
`id` bigint(20) NOT NULL ,
`room_id` bigint(20) ,
`tariff_type_id` bigint(20) ,
`tariff_from` date,
`tariff_to` date,
`single_rate` int(11),
`default_rate` int(11)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `room_tariff` (`id`, `room_id`,`tariff_type_id`,`tariff_from`, `tariff_to`, `single_rate`, `default_rate`) VALUES
(1, 1, 1, '2019-01-01', '2019-01-20',1000,2000),
(2, 1, 2, '2019-02-06', '2019-02-12',5000,10000),
(3, 2, 1, '2019-03-05', '2019-04-10',8000,7000);
CREATE TABLE `tariff_hike_day` (
`id` bigint(20) NOT NULL,
`room_id` bigint(20) ,
`tariff_type_id` bigint(20) ,
`hd_tariff_from` date,
`hd_tariff_to` date,
`hd_single_rate` int(11),
`hd_default_rate` int(11),
`thd_sunday` smallint(6) COMMENT 'Is rate applicable on Sunday 1=>yes 0=>no',
`thd_monday` smallint(6) COMMENT 'Is rate applicable on Monday 1=>yes 0=>no',
`thd_thuesday` smallint(6) COMMENT 'Is rate applicable on Tuesday 1=>yes 0=>no',
`thd_wednesday` smallint(6) COMMENT 'Is rate applicable on Wednesday 1=>yes 0=>no',
`thd_thursday` smallint(6) COMMENT 'Is rate applicable on Thursday 1=>yes 0=>no',
`thd_friday` smallint(6) COMMENT 'Is rate applicable on Friday 1=>yes 0=>no',
`thd_saturday` smallint(6) COMMENT 'Is rate applicable on Saturday 1=>yes 0=>no'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `tariff_hike_day` (`id`, `room_id`, `tariff_type_id`,`hd_tariff_from`, `hd_tariff_to`, `hd_single_rate`, `hd_default_rate`, `thd_sunday`, `thd_monday`, `thd_thuesday`, `thd_wednesday`, `thd_thursday`, `thd_friday`, `thd_saturday`) VALUES
(1, 1, 1, '2019-01-05', '2019-01-10',100,200, 1, 1, 1, 1, 1, 1, 1),
(1, 2, 1, '2019-03-09', '2019-03-25',400,600, 1, 0, 0, 1, 0, 0, 0);
The scenario is to display the room rates applicable to hotels based on rate info provided in two tables. Normally a room will have different types of rate like "Contracted Rates", "Seasonal Rates" etc and in each type, Hotel Administrative Team will provide the applicable rates and the date range in which the rates are applicable.
The problem arises when the Hotel Administrative Team wants to specify additional hikes which are applicable on certain days. This information is stored in tariff_hike_day table where the Hotel Administrative Team can specify the date range and the days (sunday, monday etc) on which the hike is to be applied on base rate.
When the full entry is completed, the system is expected to display the result as follows:
+-------+---------------+---------------+------------------+------------+------------+-------------+--------------+
| Sl No | Property Name | Room | Tariff Type | Date From | Date To | Single Rate | Default Rate |
+-------+---------------+---------------+------------------+------------+------------+-------------+--------------+
| 1 | Black Forest | Standard Room | Season Rates | 2019-01-01 | 2019-01-04 | 1000 | 2000 |
| 2 | Black Forest | Standard Room | Season Rates | 2019-01-05 | 2019-01-10 | 1100 | 2200 |
| 3 | Black Forest | Standard Room | Season Rates | 2019-01-11 | 2019-01-20 | 1000 | 2000 |
| 4 | Black Forest | Standard Room | Contracted Rates | 2019-02-06 | 2019-02-12 | 5000 | 10000 |
| 5 | Black Forest | AC Room | Season Rates | 2019-03-05 | 2019-03-09 | 8000 | 7000 |
| 6 | Black Forest | AC Room | Season Rates | 2019-03-10 | 2019-03-10 | 8400 | 8600 |
| 7 | Black Forest | AC Room | Season Rates | 2019-03-11 | 2019-03-12 | 8000 | 7000 |
| 8 | Black Forest | AC Room | Season Rates | 2019-03-13 | 2019-03-13 | 8400 | 8600 |
| 9 | Black Forest | AC Room | Season Rates | 2019-03-14 | 2019-03-16 | 8000 | 7000 |
| 10 | Black Forest | AC Room | Season Rates | 2019-03-17 | 2019-03-17 | 8400 | 8600 |
| 11 | Black Forest | AC Room | Season Rates | 2019-03-18 | 2019-03-19 | 8000 | 7000 |
| 12 | Black Forest | AC Room | Season Rates | 2019-03-20 | 2019-03-20 | 8400 | 8600 |
| 13 | Black Forest | AC Room | Season Rates | 2019-03-21 | 2019-03-23 | 8000 | 7000 |
| 14 | Black Forest | AC Room | Season Rates | 2019-03-24 | 2019-03-24 | 8400 | 8600 |
| 15 | Black Forest | AC Room | Season Rates | 2019-03-25 | 2019-04-10 | 8000 | 7000 |
+-------+---------------+---------------+------------------+------------+------------+-------------+--------------+
Any help would be appreciated.