I am not so into database and I have the following doubt:
I have this room_rate table that represent the rate reserverations of an accomodation system:
id bigint(20) unsigned NO PRI NULL auto_increment
rate_name varchar(255) NO NULL
rate double NO NULL
date_from datetime NO PRI NULL
date_to datetime NO PRI NULL
id_room_tipology_fk bigint(20) unsigned NO PRI NULL
time_stamp datetime YES NULL
I have that the primary key is composed by the following field:
1) id: an auto increment id.
2) date_from: the starting date.
3) date_to: the edning date.
4) id_room_tipology_fk: the room tipology link to another table.
A record of this table simply represent how much is the cost of a room beloning to a tipology of rooms (represented by id_room_tipology_fk) in a specific range of time represented by the date_from and date_to dates.
I want to avoid that a same room tipology have 2 records in the table in the same range of time.
I am asking if using the previous primary key subset is good or if I have to exclude the id field.
Basically I can't have something like this:
1 rate1 50 01/01/2017 10/01/2017 5 04/12/2016
2 rate2 70 01/01/2017 10/01/2017 5 06/12/2016
Because I can't have 2 rate for the same room tipology (5) in the same period.
What is the best solution to correctly model this situation?