Jump to content

Please help with database structure?


peuge

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.