简体   繁体   English

试图弄清楚我的SQL表之间的关系

[英]Trying to figure out the relationship between my tables for SQL

I have two tables 我有两张桌子

Exception which contains 其中包含的异常
Report Number(Primary Key) 报告编号(主键)
Exception Description 异常描述

Exception Date Entered 输入例外日期

Exception Downtime Hours 异常停机时间

Keyword which contains 包含的关键字

Keyword(Primary Key) 关键字(主键)

I can't figure out if this is a one to many relationship or a many to many relationship. 我不知道这是一对多关系还是多对多关系。 I know a Exception can have many keywords but can a keyword have many descriptions? 我知道异常可以有很多关键字,但是关键字可以有很多描述吗? I mean a keyword can be used in more then one report but i'm not sure totally. 我的意思是,可以在一个报告中使用一个关键字,但是我不确定。 I can add more information if needed i'm just really stumped on which it is. 如果需要的话,我可以添加更多信息,我真的很困惑。 (For this an exception means a machine broke and needs to be fixed and the keyword is what needs to be fixed) (为此,异常表示机器坏了,需要修复,而关键字是需要修复的关键字)

If Keyword is a primary key it has to be unique ie it's a one-to-many relationship. 如果关键字是主键,则它必须是唯一的,即是一对多关系。

So in this design a keyword always refers to the same thing. 因此,在此设计中,关键字始终指的是同一件事。

If a keyword needs many descriptions, then you could have another descriptions table which has a foreign key to the keywords table... 如果一个关键字需要很多描述,那么您可以拥有另一个描述表,该表具有指向该关键字表的外键...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM