对数据库规范化概念的困惑 [英] confusion on database normalization concepts

查看:62
本文介绍了对数据库规范化概念的困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果数据库中有两个表..

一种是餐桌产品

表名称:具有属性的产品(productid(pk),产品名称,productImage,单价,说明)

另一张桌子有库存

TableName:具有属性的库存(stockid(pk),productid(fk),产品名称,订单数量,交货状态,交货日期)

我想知道将商品名再次放入库存表是leagle.谁能解释.

if we have two tables in database..

one is the table products

Table Name: Products with attributes ( productid(pk), productname, productImage, UnitPrice, Description)

another table is of stock

TableName: Stock with attributes( stockid(pk),productid(fk),productname,orderquantity,delivarystatus,delivarydate)

i want to know that is it leagle to put productname again in stock table. can anyone explain this.

推荐答案

在其中插入一列是法律,但这不是一个好主意. br/> 如果要标准化这些表,则在需要时将依赖productid(fk)从products表中检索产品名称.在库存表中添加产品名称没有任何作用,实际上,当更新产品名称时,您会为此感到沮丧,因为您必须确保每次对产品进行更改时都更新库存中的产品名称.
It''s legal to put a column in there, but it is not a good idea.
If you were to normalize these tables, you would rely on the productid(fk) to retrieve the productname from the products table whenever you need to. Adding the productname in the stock table serves no purpose and will in fact cause you grief when a productname is updated as you would have to ensure that the productname in stock gets updated every time a change is made to products.


这篇关于对数据库规范化概念的困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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