简体   繁体   English

租赁系统的最佳数据库结构是什么?

[英]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: 将表用于项目,并引用ItemType表:

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 ProductID StartDate EndDate数量

Then everytime an order is placed or you manually add or remove inventory, update the inventory index: 然后,每次下订单或您手动添加或删除库存时,更新库存索引:

Inventory Index: 库存指数:

ProductID Date InventoryAvailable ProductID日期库存可用

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. 我可以分享其他我们可以使用的表格,如果有帮助的话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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