I have done one structure that may help you.
room. It's the main room configuration where you can add any value that refer to the rooms.
room_status. It's the room
status where you could know which is the room actual status.
transaction. Its your main table, here you're going to storage all the activities of the rooms.
user. Here you can delimit which user is who.
You should make a try and add the indexes in the fields your going to filter in your queries.
CREATE SCRIPT AND INFORMATION:
Tables:
CREATE TABLE `room` (
`id` int(6) NOT NULL,
`roomName` varchar(75) DEFAULT NULL,
`date` datetime DEFAULT NULL,
`status` int(2) DEFAULT NULL,
`othersfields` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `room_status` (
`idroom_status` int(2) NOT NULL,
`sName` varchar(45) DEFAULT NULL,
PRIMARY KEY (`idroom_status`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `transaction` (
`id` int(6) NOT NULL,
`room_id` int(6) DEFAULT NULL,
`check_in` datetime DEFAULT NULL,
`check_out` datetime DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`othersfields` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `user` (
`id` int(11) NOT NULL,
`fName` varchar(45) DEFAULT NULL,
`lName` varchar(45) DEFAULT NULL,
`pwd` varchar(45) DEFAULT NULL,
`rol` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Information:
mysql> SELECT * FROM test.room;
+----+----------+---------------------+--------+--------------+
| id | roomName | date | status | othersfields |
+----+----------+---------------------+--------+--------------+
| 1 | Suit | 2015-07-13 00:00:00 | 1 | NULL |
| 2 | Normal | NULL | 2 | NULL |
| 3 | Other | NULL | 1 | NULL |
+----+----------+---------------------+--------+--------------+
3 rows in set (0.00 sec)
mysql> select * from test.room_status;
+---------------+-------------+
| idroom_status | sName |
+---------------+-------------+
| 1 | Open |
| 2 | Closed |
| 3 | Maintenance |
+---------------+-------------+
3 rows in set (0.00 sec)
mysql> select * from test.user;
+----+-------+-------+------------+------+
| id | fName | lName | pwd | rol |
+----+-------+-------+------------+------+
| 1 | oNare | Test | 123ka21312 | NULL |
+----+-------+-------+------------+------+
1 row in set (0.00 sec)
mysql> select * from test.transaction;
+----+---------+---------------------+---------------------+---------+--------------+
| id | room_id | check_in | check_out | user_id | othersfields |
+----+---------+---------------------+---------------------+---------+--------------+
| 1 | 1 | 2015-07-01 00:00:00 | 2015-07-02 00:00:00 | 1 | NULL |
| 2 | 1 | 2015-07-03 00:00:00 | 2015-07-05 00:00:00 | 1 | NULL |
| 3 | 2 | 2015-07-03 00:00:00 | 2015-07-04 00:00:00 | 1 | NULL |
| 4 | 1 | 2015-07-13 00:00:00 | NULL | 1 | NULL |
| 5 | 2 | 2015-07-09 00:00:00 | 2015-07-13 00:00:00 | 1 | NULL |
+----+---------+---------------------+---------------------+---------+--------------+
5 rows in set (0.00 sec)
mysql>
Test query:
mysql> SELECT
-> r.id AS idRoom,
-> r.roomName,
-> rs.sName as Status,
-> t.check_in,
-> t.check_out
-> FROM test.transaction AS t
-> JOIN test.room AS r ON (t.room_id=r.id)
-> JOIN test.room_status AS rs ON (rs.idroom_status=r.status)
-> JOIN test.user AS u ON (t.user_id=u.id);
+--------+----------+--------+---------------------+---------------------+
| idRoom | roomName | Status | check_in | check_out |
+--------+----------+--------+---------------------+---------------------+
| 1 | Suit | Open | 2015-07-01 00:00:00 | 2015-07-02 00:00:00 |
| 1 | Suit | Open | 2015-07-03 00:00:00 | 2015-07-05 00:00:00 |
| 1 | Suit | Open | 2015-07-13 00:00:00 | NULL |
| 2 | Normal | Closed | 2015-07-03 00:00:00 | 2015-07-04 00:00:00 |
| 2 | Normal | Closed | 2015-07-09 00:00:00 | 2015-07-13 00:00:00 |
+--------+----------+--------+---------------------+---------------------+
5 rows in set (0.00 sec)
mysql>