在ERD中获得主键和外键 [英] To get primary and foreign keys right in ERD

查看:201
本文介绍了在ERD中获得主键和外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了我的笔记,我现在不确定这些键。

I read my notes and I am now unsure about the keys.

我的逻辑图

alt text http://files.getdropbox。 com / u / 175564 / db / db-11.png

此表格应符合以下实体ERD

This table should be in line with the following physical ERD

alt text http:// files。 getdropbox.com/u/175564/db/db-22.png

我在表格中只有一个外键问题

I have only one foreign key in the table Question.

我想知道


  • 应该在表中 Question-tag-xref 中的 question-id 问题标记 / li>
  • should the question-id and question-tag in the table Question-tag-xref, AND question-id and answer in the table Answers be also foreign keys?

推荐答案

Masi - 逻辑模型通常不包含数据类型(string,int等)信息,但是指示属性(成为物理模型中的列)是否是可选的(可以为空或不为空)。

Masi - Logical models don't usually contain data type (string, int, etc) information, but do indicate if the attribute (becomes a column in the Physical model) is optional (able to be null or not).

-ID和QUESTION-TAG列将是QUESTION-TAG-XREF表中的外键。以下是QUESTION-TAG-XREF的物理视图:

That said, yes - the QUESTION-ID and QUESTION-TAG columns would be foreign keys in the QUESTION-TAG-XREF table. Here's a physical view of QUESTION-TAG-XREF:

QUESTION-TAGS-XREF


  • QUESTION-ID(与QUESTIONS表格的pk,fk关系)

  • QUESTION-TAG-CODE(pk,fk与QUESTION-TAG表格的关系)

这两列都是pk,以确保您不能对给定问题出现重复的标签。

Both columns are the pk to ensure you can't have duplicate tags for a given question.

您提供的QUESTION表中的QUESTION-ID是否为ANSWERS表中的外键是正确的。

You are correct that QUESTION-ID would be a foreign key in the ANSWERS table, in reference to the QUESTION table.

这篇关于在ERD中获得主键和外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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