简体   繁体   中英

What is the best database structure for a rental system?

I have done rental systems for boats and reservation for rooms and tours apart.

But how could I build up a database which I could use for multiple type of items? It means the items can be rooms, trips, journeys, cars, boats, etc...

Thanks!

Use a table for your items with a reference to an ItemType table:

Item

ItemId    ItemType      HireDate   Hirer
1         2             1 Jan      200
2         3             3 Jan      201
3         6             4 Jan      207

ItemType

ItemTypeID  Desc
2           Boat
3           Car
4           Bike

In our rental system I can share the sort of table that we use.

You will need a reservation orders table, and a inventory index that gets updated after each order. Or else you will have terribly slow inventory lookups.

Reservation Orders:

ProductID StartDate EndDate Quantity

Then everytime an order is placed or you manually add or remove inventory, update the inventory index:

Inventory Index:

ProductID Date InventoryAvailable

You will have an entry for each date in your Inventory Index so it will get pretty large, but else there is no fast way to check inventory.

We use this in our rental system here: rental booking software example

I can share other tables we use if that will help, let me know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM