数据库设计较大的表与拆分表具有相同的列 [英] database design bigger table vs split table have the same col

查看:52
本文介绍了数据库设计较大的表与拆分表具有相同的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有一个用于存储的数据库程序,如您所知,其中一种发票是我购买的东西,另一种是我出售的,当我卖给他们时,这两个表几乎相同,就像

发票表
ID
customerName
日期
invoiceType


和发票详细信息
id
invoiceId
项目
价格
金额

我的问题很简单,什么是最好的保持设计不变的方法,还是将每张桌子分成两个分开的表格
我的几个朋友建议将表格拆分为一个用于salesInvoice的表格和将另一个用于buyInvoice的表格,以缩短查询时间
所以每个abrouch的利弊是什么,我觉得如果我将它们拆分,就好像我不遵循DRY规则.拆分表.

一个应该是采购订单,另一个应该是发票.收到发票后,请对照采购订单进行检查.采购订单将有一个供应商,发票将有一个客户.不要将两者混在一起!

这不是查询时间,它只是使确定正在发生的事情变得更加容易(并且出于法律原因,您必须确定)-它还允许您限制谁可以访问哪个表:购买(由谁生成) POs)不需要访问发票,反之亦然,客户帐户部门也是如此.


我主要关心的是查询时间,我可以限制谁可以通过我的代码访问什么内容
为什么我应该对每个存储过程做两次以处理两个表而不是一个表


hi i have a database program for store as you know there is too type of invoice in it one for the thing i bought and the other for me when i sold them the two table is almost identical like

invoice table
Id
customerName
date
invoiceType


and invoiceDetails which have
id
invoiceId
item
price
amount

my question is simple its what best to keep the design like that or split every table for two sperate tabels
couple of my friend suggest splitting the tables as one for saleInvoice and the other for buyInvoice to speed the time for querying
so whats the pro and con of every abrouch i feel that if i split them its like i dont follow DRY rule

解决方案

No. Split your tables.

One should be Purchase orders, the other is Invoices. When you receive an invoice, you check it against Purchase orders. POs will have a supplier, Invoices will have a customer. Do not mix the two!

It''s not the query time, it just makes it easier to be sure what is going on (and for legal reasons you have to be sure) - it also allows you to restrict who has access to what table: purchasing (who generate POs) should not need access to invoices, and vice versa for the customer accounts dept.


my main concern is the query time i can restrict who access what through my code
why should i do every stored procedure twice in order to work with two tables instead of one


这篇关于数据库设计较大的表与拆分表具有相同的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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