如何在MySQL中实现具有共同属性的两个实体?
我正在设计一个医生办公室和药房的数据库模型,要求存储有关客户和患者的数据,客户是在药房购买的人和患者看病的同时,顾客也可以有耐心,反之亦然。如何应对这种情况?如果我为每个人创建一个实体,那么一个人很可能会同时出现在两张桌子上。有什么建议吗?
I am designing a database model of a doctor's office and pharmacy and the requirements ask to store data about customers and patients, a customer is somebody who buys in the pharmacy and a patient who see the doctor, a customer can be patient at the same time and viceversa. How to manage this situation? If I create one entity for each one then, there is the probability that a person would be on both tables. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
两种方法:
一个名为 Persons 表的表,具有可以为 true/false 的文件“is_customer”和“is_Patent”
三个表,一个用于存储所有具有唯一 ID 的相关数据(姓名、地址、电话号码等)的人员,一个用于患者的表,它只是一张包含唯一 ID 和引用的表人员表,以及一个用于客户的表,该表只是一个包含唯一 ID 和对人员表的引用的表。
Two methods:
One table called persons table, has files 'is_customer' and 'is_patient' that can be true/false
Three tables, one for people which stores all of their relevant data (names, address, phone number, etc) with a unique ID, one table for patients which is just a table of unique id's and references to the people table, and one table for customers which is just a table of unique ids and references to the people table.