发票&发票行:您如何存储客户地址信息? [英] Invoice & Invoice lines: How do you store customer address information?

查看:175
本文介绍了发票&发票行:您如何存储客户地址信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



所以一般的想法是要有两个表:



发票(ID,日期,客户地址,客户状态,客户国家,增值税,总计);
InvoiceLine(Invoice_ID,ID,Concept,Units,PricePerUnit,Total);



正如你所看到的那样,这个基本设计会导致很多重复的记录,客户端将拥有相同的地址,州和国家/地区。



所以替代方法是拥有一个地址表,然后建立一个关系Address< -Invoice。



但是我认为发票是不可变的文件,应该是首先存储的方式。有时候,客户会改变他们的地址,或者说是来自地址目录,它会改变以前所有的发票。



那么你的经历是什么? >

客户地址如何存储在发票中?在发票表中?地址表?还是别的东西?



你能提供一个指向一个书,文章或文档的指针,这个更详细的讨论吗?

解决方案

我强烈建议不要在发票中存储任何客户详细信息。



相反,我会有一个结构如:



客户表格,主键为id



客户地址表(每个客户可能有不同的地址随着时间的推移),客户ID作为外键



发票表,地址字段是客户地址表的外键。



BTW,我会考虑为每个订单项添加一个增值税字段。有不同类型的国家有不同的增值税税率。


Hi I'm developing an invoicing application.

So the general idea is to have two tables:

Invoice (ID, Date, CustomerAddress, CustomerState, CustomerCountry, VAT, Total); InvoiceLine (Invoice_ID, ID, Concept, Units, PricePerUnit, Total);

As you can see this basic design leads to a lot of repetiton of records where the client will have the same addrres, state and country.

So the alternative is to have an address table and then make a relationship Address<-Invoice.

However I think that an invoice is immutable document and should be stored just the way it was first made. Sometimes customers change their addresses, or states and if it was coming from an Address catalog that will change all the previously made invoices.

So What is your experience?

How is the customer address stored in an invoice? In the Invoice table? an Address Table? or something else?

Can you provide pointers to a book, article or document where this is discussed in further detail?

解决方案

I would strongly recommend against storing any customer details like that in the Invoice.

Instead, I would have a structure like:

Customer table, with a primary key of id

Customer address table (as each customer may have different addresses over time), with the customer id as a foreign key

Invoice table, with an address field that is a foreign key to a customer address table.

BTW, I would consider adding a VAT field per line item. There are countries where there are different VAT rates for different item types.

这篇关于发票&amp;发票行:您如何存储客户地址信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆