如何设计表格 [英] How to design the table

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

问题描述

我有如下表格

t_company有companyid,companyname;

t_department有departmentid,departmentname,companyid;

t_goodstype有goodstypeid, goodstypename,departmentid;

t_goods有货物,商品名称,goodstypeid;



在我的项目中,很多时候我想看货物和一个公司有一个好的。

表格设计得好。

或者应该像tableid一样添加一行到表t_goodstype和t_goods;

I have tables like below
t_company has companyid, companyname;
t_department has departmentid, departmentname, companyid;
t_goodstype has goodstypeid, goodstypename, departmentid;
t_goods has goodsid, goodsname, goodstypeid;

In my project, in many times I would like to see goods and goodstype a company has.
Is the table up good designed.
Or should add a row like companyid to table t_goodstype and t_goods;

推荐答案

你的桌子设计很好。您可以通过将表连接到您想要的输出来创建VIEW,而不是创建新表。考虑你要过滤的参数是什么,以及你想要输出的数据字段是什么。



你也可以为此创建一个用户自定义表函数目的。

性能明智,它取决于数据和过滤标准。我已经看到了从视图移动到UDF以及从UDF移动到视图的性能改进。
Your table design is good. Instead of creating a new table, you can create a VIEW by joining the table to giving the output as you like. consider what are the parameter you want to filtering out and what are the data fields you want to get as output.

Also you can create a User Defined Table Function for this purpose.
Performance wise, "it depends" on the data and the filtering criteria. I''ve seen performance improvements from moving from views to UDFs, and also from moving from UDFs to views.


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

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