您可以在Access 2007中使用幻数吗? [英] Can you have magic numbers in Access 2007?

查看:111
本文介绍了您可以在Access 2007中使用幻数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将数字存储在访问"列中,然后将一些有意义的字符串与每个值相关联?

How do I store numbers in an Access column and then associate some meaningful string to each value?

因为当我一次可以定义每个值的含义并将这些含义显示在数据表视图中时,我不想看到原始数字,例如:

Because I don't want to be seeing raw numbers when I can define the meaning of each value once at for all, and have those meanings displayed in the Datasheet View, like:

ID  Name      Type

1   Jack      1 (Friend)
2   Jill      1 (Friend)
3   Diago     2 (Enemy)
4   Sally     3 (Colleague)

推荐答案

您可能需要至少两个不同的表.一个具有该人的ID和名称的表,另一个具有该人与该人的关系的类型和描述的表.

You probably want at least two different tables. One that has the ID and Name of the people, and another table with the Type and Description of how they're related to that person.

如果一个人可以有多个关系(例如,朋友和同事),则您将拥有第三个表,该表的一列是该人的ID,另一列是该关系Type的ID.如果一个人只能拥有一种类型的关系,则只需在其Person表中添加第三列,其ID为该人的类型.

If a person can have more than one relationship (e.g. a Friend and a Colleague), you would have a third table that has one column for the ID of the person and another column for the ID of the relationship Type. If a person can only ever have one type of relationship, they you could simply add a third column to your Person table with the ID of the Type of person they are.

要从表中获取数据,您可以在SQL语句中使用JOIN通过为每个表指定的ID将所有表的行连接在一起.

To get data out of the tables, you can use JOINs in your SQL statements to join the rows of all of the tables together by the IDs you have specified for each.

通常,这是一个链接,它描述了有关关系数据库的全部内容.这是一个 Microsoft Office链接,该主题讨论了使用主数据库在表之间创建关系以及Access中的外键约束可能会帮助您. 这里是另外一个,其中包含逐步说明和一个非常相关的示例(学生和年级).

In general, here's a link that describes what relational databases are all about. Here's a Microsoft Office link that talks about creating relationships between tables using primary and foreign key constraints in Access that might help you out. Here's another with step by step instructions and a fairly relevant example (Students and Grades).

这篇关于您可以在Access 2007中使用幻数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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