SQL数据库设计-如何 [英] SQL Database Design - How To

查看:187
本文介绍了SQL数据库设计-如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个桌子.具有15个字段的Table1具有6个字段的Table2.在这6个字段中,有5个字段将共享与表1中相同的数据.这意味着,如果更新了Table1,我还必须更新Table2,除了这个Table2还将拥有自己的数据.

我的问题是我应该摆脱Table2并向Table1添加一个额外的字段,在这种情况下,其余9个字段对于之前进入Table2的数据将具有空值.

或者我保留Table2;但是在那种情况下,我将不得不以编程方式维护两个表,这将导致数据重复.这两个表的数据始终匹配是非常重要的,因为这是程序的核心.

在此先感谢.

I have two tables; Table1 with 15 fields Table2 with 6 fields. Among these 6 fields 5 fields will share same data as in Table1. Which means If Table1 is updated I have to update Table2 as well, apart from this Table2 will have its own data as well.

My question is should I get rid of Table2 & add one extra field to Table1, in this case the remaining 9 fields will have null values for the data that was going into Table2 before.

Or I keep Table2; but in that case I will have to programmatically maintain both tables, which will cause data duplication. It is very important that the data of these two tables always match as it is the heart of the program.

Thanks in Advance.

推荐答案

我建​​议第三个解决方案.创建第三个表,它将包含上一个表共有的5个字段和一些Id字段.在这种情况下,您将在表1和表2中仅按ID引用所需数据.

共享数据应始终保存在一个位置.
I recommend third solution. Create third table which will be contain 5 fields common to previous table and some Id field. In this case you will kept in table1 and table2 only reference by id to needed data.

Share data always should be kept in one place.


这篇关于SQL数据库设计-如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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