[英]MS Access - Linking field value to column
I have two tables in Access i am trying to relate: Products & Prices. 我要关联的Access中有两个表:产品和价格。
Following is a simplified example 以下是一个简化的示例
ProductCode ProductName
A Sugar
B Salt
C Bread
Date A B C
01/02/2016 $1 $2 $3
I do not want to split the prices table as follows: 我不想按以下方式拆分价格表:
Date Code Price
01/02/2016 A $1
01/02/2016 B $2
01/02/2016 C $3
Excuse my ignorance, as i am new to Access. 对不起,因为我是Access新手。
Thanks for the advice. 谢谢你的建议。
Probably not the answer you expect, but here it is anyway: 可能不是您期望的答案,但是无论如何,这里是:
Access is a relational database , and when using it you are supposed to follow some design rules for your tables. Access是一个关系数据库 ,使用它时,应该遵循一些表设计规则。 Search the web for "database normalisation" (eventually normali z ation). 搜索“数据库规范化”(最终normaliž通货膨胀)网络。
For instance, your Prices
table is not properly designed: should you ever have a 4th product, it would require modification of the table structure. 例如,您的Prices
表设计不正确:如果您有第四种产品,则需要修改表结构。 A better design would be something like: 更好的设计应该是这样的:
PriceId as AutoNumber
dtReplaced as date 'leave Null for 'active' prices
ProductCode as string
Price as Currency
with a PK on PriceId and Unique Index on ProductCode + dtReplaced to avoid having 2 active prices for the same product. 在PriceId上使用PK,在ProductCode上使用唯一索引+ dtReplaced以避免同一产品具有2个有效价格。
Also note that Date
is a reserved word, and should not be used as a field name, unless your are really looking for trouble. 还要注意,“ Date
是保留字,不应用作字段名,除非您确实在找麻烦。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.