Hi I’m newbie in Programming especially in Database Design.
I’ve just started to work with database and I wonder to know Which one of these designs give me better performance and are more rational.
I have built reservation Hotel table Like these:
Set DateIn and DateOut for each Resevation
Set Flag for each Room/Day

Hypothetically we have max 100 rooms so if I want to generate table(for 50 years) for second picture approximately It takes 15MB((100(room)*8(bit)+3(Date))*365(Day)*50(year)) of capacity but I think when I want to query, it gives me better performance.
query of first picture is more complex and I think less performance
I would Appreciate if you give me the reason or better approach.
Thanks in Advance
I mean, It really has to do more with how you’re planning on accessing and altering the data. I’d recommend the first one in pretty much every case, but I won’t deny there may exist edge cases where the second is better. I doubt yours is such a case.
The first provides a more reasonable approximation for how people think about reservations (which is good) – it also subtly encodes who is going to be staying in which rooms on which days, connecting it relationally to the rest of your DB with thinks like reservation information, guest information. These provide you with the ability to re-imagine data relationships down the line when you’re attempting to glean insight from the data you’re collecting. For instance. After ten years, what would you do if the CEO said “Hey, what have been our historically most popular dates of the year? With the ‘Reservation’ model, you could easily write a programmatic query to find that out. With the ‘Date/Room Matrix’ model, you’re going to have to manually check every single column. Gross.
While the second model is great for a hotel that never plans to change, what if rooms need to be placed in and out of rotation? Another 100 column table with booleans for which rooms are available to the public on which days? Conflating occupied with out of order? What if you add a wing? Are you going to add another 25 columns to this table, etc etc? It will likely offer you some operational efficiency for “Which rooms are available right know?” – but how would you structure a query for “Which rooms will be available from August 3rd through sixth?”
Remember that in a relational database, you’re selecting a specific set of rows based on what the values in their columns are, you’ll have a much harder time selecting a set columns basted on what their row values are.