简体   繁体   English

ER 图,物理数据 Model 关系

[英]ER Diagram, Physical Data Model Relations

I am trying to create a very simple database Supermarket management system.我正在尝试创建一个非常简单的数据库超市管理系统。 And it seems that I am having a problem with how relations work between entities, I am using PowerDesigner to create the ERD and then generate everything from it(LDM, PDM, OOM).似乎我对实体之间的关系如何工作有疑问,我正在使用 PowerDesigner 创建 ERD,然后从中生成所有内容(LDM、PDM、OOM)。 Is this a bad idea?.这是一个坏主意吗?。

Now for my main problem It's between these 3 tables:现在我的主要问题是在这三个表之间:

  1. Employee(Cashier)员工(收银员)
  2. Customer顾客
  3. Orders(Receipt).订单(收据)。

The way I did it is:我这样做的方式是:
The customer gather the products he wants to buy and present it to the employee, then the employee gets the order for the customer from the machine, so:客户收集他想要购买的产品并将其展示给员工,然后员工从机器中获取客户的订单,因此:

  1. There is a relation between the Customer and the Employee (Many to Many): each customer can request_order from one or more Employee and each Employee can get_order to one or more Customer.客户和员工之间存在一种关系(多对多):每个客户可以向一个或多个员工请求订单,每个员工可以向一个或多个客户获取订单。
  2. There is a relation between the Employee and the Orders (1 To Many): each Employee can get one or more orders, each order is fetched by one employee. Employee 和 Orders 之间存在关系(一对多):每个 Employee 可以获得一个或多个订单,每个订单由一个员工获取。 The problem is if I want to know the customer related to that specific order......I can't.问题是如果我想知道与该特定订单相关的客户......我不能。 How do I fix this?我该如何解决? How can I get the specific order that customer made.我怎样才能得到客户下的具体订单。 I am still very new to this, so sorry for any obvious mistakes.我对此还是很陌生,对于任何明显的错误,我深表歉意。

在此处输入图像描述

I am sticking to the Relational Database context, that you have tagged.我坚持使用您已标记的关系数据库上下文。

Data Modelling is an iterative process.数据建模是一个迭代过程。 There is a lot more definition that is needed, before the data model can be complete.在完成数据 model 之前,还需要更多定义。 Rather than answering the specifics that you request, which would be limited to one iteration;而不是回答您要求的细节,这将仅限于一次迭代; one increment, allow me to provide something more complete, several iterations progressed.一个增量,请允许我提供更完整的东西,进行了几次迭代。

超市数据模型

If it is useful, please discuss this data model, and progress it to fulfil all your requirements.如果有用,请讨论此数据 model,并进行改进以满足您的所有要求。

  • Of course it is too small as an inline graphic.当然,它作为内联图形太小了。 As a PDF Supermarket Data Model .作为 PDF 超市资料 Model

  • The Standard for Relational Data Modelling since 1983 is IDEF1X.自 1983 年以来的关系数据建模标准是 IDEF1X。 For those unfamiliar with the Standard, refer to the short IDEF1X Introduction .对于不熟悉该标准的人,请参阅简短的IDEF1X 简介

I am using PowerDesigner to create the ERD and then generate everything from it (LDM, PDM, OOM).我正在使用 PowerDesigner 创建 ERD,然后从中生成所有内容(LDM、PDM、OOM)。 Is this a bad idea?.这是一个坏主意吗?。

  1. PowerDesigner is great. PowerDesigner 很棒。 Just ignore the Oracle-specific nonsense, it pushes you into considering the physical far too early.忽略 Oracle 特有的废话,它会让你过早地考虑物理。
  2. Skip the ERD, it is brain-dead in the context of the Relational paradigm, and surpassed by IDEF1X, which is specific to that paradigm.跳过 ERD,它在关系范式的上下文中是脑死的,并且被特定于该范式的 IDEF1X 超越。
    • Use the Entity Level display for ERD equivalence.使用 ERD 等效的实体级别显示。
  3. For small projects you can ignore the academic distinctions {CDM;对于小型项目,您可以忽略学术区别 {CDM; LDM; LDM; PDM;个人资料管理; OOM, etc}. OOM 等}。
    • There is actually just one model: it is "conceptual" at the beginning, and you just progress to "logical", and last, when the "logical" is stable, to the "physical".实际上只有一个 model:一开始是“概念性的”,然后您就进入“逻辑”,最后,当“逻辑”稳定时,进入“物理”。
    • Understand that the whole process is Logical.了解整个过程是合乎逻辑的。
    • Unfortunately, in PD you have to have separate "models" or files for each.不幸的是,在 PD 中,您必须为每个单独的“模型”或文件。

Now for my main problem It's between these 3 tables:现在我的主要问题是在这三个表之间:

I have solved that issue.我已经解决了这个问题。 And exposed others.并暴露了其他人。

each customer can request_order from one or more Employee and each Employee can get_order to one or more Customer每个客户可以从一个或多个员工请求订单,每个员工可以向一个或多个客户获取订单
each Employee can get_order to one or more Customer每个 Employee 可以 get_order 给一个或多个 Customer

Yes, but that is the overall result.是的,但这是总体结果。 In each shopping or presentation instance:在每个购物或演示实例中:

  • a customer can request_order from one Employee (Cashier)客户可以向一名员工(收银员)请求订单
  • a Employee can get_order from one Customer员工可以从一个客户那里获取订单

The problem is if I want to know the customer related to that specific order......I can't.问题是如果我想知道与该特定订单相关的客户......我不能。 How do I fix this?我该如何解决?

Solved: Each Order is Identified by (CustomerId, DateTime) , ie.已解决: Each Order is Identified by (CustomerId, DateTime) ,即。 the Customer who created the Order .创建OrderCustomer

Note笔记

  1. Do not mix Process elements (eg. Get_Order) with Data elements (eg. the data model).不要将流程元素(例如 Get_Order)与数据元素(例如数据模型)混合。 The two areas are separate, and governed by quite different science.这两个领域是分开的,并且由完全不同的科学管理。 Here we are solving the Data;在这里,我们正在解决数据; only the Data;仅数据; and nothing but the Data.只有数据。 After that, the Process Model is easy.之后,过程 Model 就很容易了。
  2. RecordIds are anti-Relational. RecordIds是反关系的。 They are certainly not needed in a Relational database.关系数据库中当然不需要它们。 Read my other Answers for detailed explanations.阅读我的其他答案以获取详细说明。
  3. Relational Keys (aka Compound Keys or Composite Keys) are standard fare in a Relational database.关系键(又名复合键或复合键)是关系数据库中的标准费用。 They provide far more integrity than a RecordId based file ever can.它们提供的完整性远远超过基于RecordId的文件。
  4. You need to be more precise (state the exact sequence) in defining how an Order is created.在定义如何创建订单时,您需要更加精确(说明确切的顺序)。

Please feel free to comment or ask specific questions.请随时发表评论或提出具体问题。

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

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