[英]Database Schema for Consignment Inventory
I'm developing a consignment inventory for hospitals, 我正在为医院开发寄售清单,
The infrastructure is this: 基础结构是这样的:
Multiple Suppliers
Multiple Warehouses
Multiple Hospitals
I'm stuck on deciding whether to make a separated stock tables
for EACH hospitals
and warehouses
or store them all in one stock table
. 我一直在决定是为每个
hospitals
和warehouses
制作单独的stock tables
,还是将它们全部存储在one stock table
。
My current plan is this: 我当前的计划是这样的:
They are all going to read on a single item table
for general item information only, then the stocks, stock movements, consign orders, employees, patients will have separate tables per hospital/warehouses. 他们将仅在单个
item table
上阅读以获取常规项目信息,然后每个医院/仓库的库存,库存移动,寄售订单,员工,患者将有单独的表。
Example: 例:
Separated Tables 分隔表
tbl_items //centralized item information
tbl_suppliers //centralized supplier information
tbl_warehouse1id_stocks
tbl_warehouse1id_stockmovements
tbl_warehouse2id_stocks
tbl_warehouse2id_stockmovements
tbl_hospital1id_stocks
tbl_hospital1id_stockmovements
tbl_hospital1id_employee
tbl_hospital1id_patients
tbl_hospital2id_stocks
tbl_hospital2id_stockmovements
tbl_hospital2id_employee
tbl_hospital2id_patients
Merged Tables 合并表
tbl_items //centralized item information
tbl_suppliers //centralized supplier information
tbl_warehouse_stocks //where warehouse_ids are primary keys
tbl_warehouse_stockmovements //where warehouse_ids are primary keys
tbl_hospital_stocks //where hospital_ids are primary keys
tbl_hospital_stockmovements //where hospital_ids are primary keys
tbl_hospital_employee //where hospital_ids are primary keys
tbl_hospital_patients //where hospital_ids are primary keys
which is better? 哪个更好? for maintaining, speed optimization etc.?
用于维护,速度优化等? my current opinion is that the separated approach is better because why should (for example) hospital1 search for their certain stock of items to the pool of stocks of all hospitals?
我目前的观点是,分开的方法更好,因为例如(医院)为什么要从所有医院的库存中搜索他们的特定物品库存? does this affect the speed?
这会影响速度吗? if hospital1 tries to query their entire stock record, it will affect the query time of other hospital because hospital1 is currently searching for their records.
如果hospital1试图查询其全部库存记录,则将影响其他医院的查询时间,因为hospital1当前正在搜索其记录。 of course indexing should help but still.
当然索引应该有帮助,但仍然可以。
EDIT: 编辑:
The server resides on a single location and its a web-based system. 该服务器位于单个位置,并且其基于Web的系统。
I would highly recommend taking the MERGED TABLES approach that you've laid out. 我强烈建议您采用您提出的合并表格方法。
Disadvantages of Separate Tables: 单独表的缺点:
Unless you have significant constraints that you haven't laid out (extremely large db with billions of rows or poor hardware that you can't scale up), indexes are designed to exactly help with this scenario. 除非您有尚未布置的重大约束(拥有数十亿行的极大型数据库或无法扩展的不良硬件),否则索引将专门为这种情况提供帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.