peuge Posted July 14, 2008 Share Posted July 14, 2008 I currently have a project for someone who wants a scooter rental site. So to start off with a need a db plan. Now I have thought about it and googled it out so many times. I was just wandering how one would go about handling this? It shouldn't be too hard as he only rents out one kind of scooter. Where I get lost is how one would store the availability for the scooters? Was thinking along the lines of an entry for each scooter, thus each scooter will have its own booked/free time. This way the user won't be able to book for 7days if only one scooter can give three and the other give four (we dont want to have to swap scooters). But now what is the best way to do this? Do we have a table with all the days in the year (isnt this stupid)? Please could anyone help or steer me in the right direction, I haven't done alot of db management and this is killing my brain!!!! Thanks in advance Quote Link to comment Share on other sites More sharing options...
fenway Posted July 14, 2008 Share Posted July 14, 2008 That's not a very clear description of the database you want to design... try being more specific. Quote Link to comment Share on other sites More sharing options...
peuge Posted July 15, 2008 Author Share Posted July 15, 2008 Sorry for that. So far from what I have been reading I have something along the lines of this: tbl_users: usr_id name surname email etc etc.... Then I have the table for the bikes. tbl_scooters scooter_id reg_plate (Because all the scooters are the same model I dont think I need any more?) Now I have the bookings table: tbl_bookings booking_id user_id scooter_id date_take date_return Ok so now the thing which is confusing me is how I am going to query this db. If a potential customer wants to reserve a bike from x to y I have to query the bookings table and find out which bikes are booked for those days meaning all the other bikes are not, right? But what is the most efficient way of doing this? So far I have thought of running a loop and selecting * FROM tbl_bookings WHERE date_take = the requested date. Then doing the same for every day in between. I have a feeling this is completely the wrong way to do it? Because if a scooter was taken on day x-1 then it will be shown as available. Sorry about the earlier post, was super tired.... Any help again is much appreciated. Thanks Quote Link to comment Share on other sites More sharing options...
fenway Posted July 15, 2008 Share Posted July 15, 2008 You just need to make sure that they requested range and any booked ranges don't overlap. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.