规范化数据库表 [英] normalizing database tables

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

问题描述

我要开发一个数据库表,将疾病与其症状联系起来.在这种情况下,我的首要目标是让我患有多种疾病,每种疾病都有自己的症状,并且一种疾病可以共享另一种症状的症状,那么我该如何建立他们的关系.

例如:

disease A: has symptoms: a ,b ,c ,d
disease B: has symptoms: e ,a ,d ,f,g
disease C: has symptoms: k ,l, g ,b ...
and soon how can i relate them in adatabase

感谢您的U.r帮助.

解决方案

添加一个名为Disease的表和另一个名为Symptoms的表(均具有主键).

将所有疾病名称(A,B,C)放在疾病"表中.

例如
疾病编号-1,2,3
疾病名称-A,B,C

将所有症状(a,b,c)放在症状"表中.

例如
症状ID-1,2,3
症状名称-a,b,c

创建一个名为DiseaseSymptoms的第三个表-在此处将疾病名称ID与症状ID相对应.

疾病编号-1,
症状ID-2,1,3,4
疾病编号-2
症状ID-5,2,1

等等...


1种疾病有很多症状,但许多疾病中可能会出现1种症状,这与多对多关系,您的真正问题是要施加多大的体重每种疾病的症状.
正如Abhinav S所指出的那样,您只需要3个表即可对所描述的内容进行建模,但是当您患有两种或多种表现出相似症状的疾病时,会发生什么,那么那应该是医生应该接受的培训. />

i wana to develop a database table that relates disease with their symptom. in this case my first aim is i have many disease each having their own symptom and one disease can share the symptoms of another symptom how can i create their relationship.

example:

disease A: has symptoms: a ,b ,c ,d
disease B: has symptoms: e ,a ,d ,f,g
disease C: has symptoms: k ,l, g ,b ...
and soon how can i relate them in adatabase

thank U for U''r Help.

解决方案

Add a table called Disease and another called Symptoms (both have primary keys).

Put all disease names (A,B,C) in the Disease table.

e.g.
Disease Id - 1,2,3
Disease Name - A,B,C

Put all symptoms (a,b,c) in the Symptoms table.

e.g.
Symptom Id- 1,2,3
Symptom name - a,b,c

Create a third table called DiseaseSymptoms - put the diseasename id against the symptom id here.

Disease Id - 1,
Symptom Id - 2,1,3,4
Disease Id - 2
Symptom Id - 5,2,1

and so on....


1 disease has many symptoms, but 1 symptom can appear in many diseases, it''s a many to many relationship, your real issue is what weight to apply to each symptom for a disease.
As Abhinav S pointed out you only need 3 tables to model what you are describing but what happens when you have two or more disease that present similar symptoms, but then that is what doctors are supposed to be trained in.


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

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