简体   繁体   English

数据库设计:发票建模

[英]Database design: invoice modeling

I'm currently working on a project in which i'm about to make a conceptual model for car retail. 我目前正在从事一个项目,其中我将为汽车零售建立概念模型。 My major problem is dealing with 1 to 1 realtionship between Invoice_Line table, which is obviously in N-1 relationship with Invoice table, and a table called Car which is supposed to hold information about specific car with it's unique registration number. 我的主要问题是处理Invoice_Line表(该表显然与Invoice表具有N-1关系)和一个名为Car的表之间的1:1关系,该表应该使用唯一的注册号保存有关特定汽车的信息。 As far as i know it wouldnt be a problem if i have made the Car table containing only information about specific type of a car, that is it's model, class, etc. However what i want is the invoice looking like that: 据我所知,如果我制作的Car表仅包含有关汽车的特定类型的信息,那就是它的型号,类别等,那将不是问题。但是我想要的发票看起来像这样:

  1. ...car_registration_number... ...price... ...date... ...车辆登记号...价格...日期...
  2. ... ...

That would mean making a 1 to 1 realtionship between invoice_line and table with specific car_id's, which i want to avoid at all cost. 这意味着要在invoice_line和具有特定car_id的表之间进行一对一分配,我想不惜一切代价避免这种情况。 What are the further possibilities to solve that? 还有其他解决方案吗? Because of distinguishable car's each invoice line would hold only 1 car, which is my way of designing it. 由于可区分的汽车,每个发票行只能容纳1辆汽车,这是我设计的方式。

An invoice line appears in one invoice so say so in Invoice_Line : 发票行会显示在一张发票中,因此请在Invoice_Line这样说:

UNIQUE NOT NULL (invoice, invoice_line_number)

The invoices must all appear in Invoice so say so: 发票必须全部出现在Invoice所以请这样说:

FOREIGN KEY (invoice_number) REFERENCES Invoice (invoice_number)

A car is unique in Invoice_Line so say so: 汽车在Invoice_Line是唯一的,所以说:

UNIQUE NOT NULL (car_registration_number)

The cars must all appear in Car so say so: 汽车必须全部出现在Car所以请这样说:

FOREIGN KEY (car_registration_number) REFERENCES Car (car_registration_number)

There is a 1:1 relationship between invoice lines and invoiced cars. 一个1:发票行和发票汽车之间一对一的关系。 But it is not a problem because that relationship is represented by car + invoice line pairs (car + invoice + invoice line number triplets) in Invoice_Line . 但这不是问题,因为该关系由Invoice_Line的car +发票行对(car +发票+发票行号triplets)表示。

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

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