自然连接中元组的最大和最小数目 [英] maximum and minimum number of tuples in natural join

查看:272
本文介绍了自然连接中元组的最大和最小数目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰到一个问题,指出

考虑以下与学生有关的关系模式

Consider the following relation schema pertaining to a students

  • 数据库:学生( rollno ,姓名,地址)
  • 注册( rollno,courseno ,课程名称)
  • database: Student (rollno, name, address)
  • Enroll (rollno, courseno, coursename)

其中主键显示有下划线的地方.中的元组数 学生表和注册表分别为120和8.最大值是多少 以及(学生*入学人数)中可以包含的最小元组数, 其中"*"表示自然连接?

where the primary keys are shown underlined. The number of tuples in the Student and Enroll tables are 120 and 8 respectively. What are the maximum and minimum number of tuples that can be present in (Student * Enroll), where '*' denotes natural join ?

我在Internet上看到了几种解决方案,例如

I have seen several solutions on Internet like this or this

根据我的理解.最大元组应该为8,最小元组也应该为8,因为每个(rollnum,course)的学生人数都应该为一轮.在这方面可以提供帮助的任何人

As per my understanding. maximum tuples should be 8 and minimum should be 8 as well, since for each (rollnum,course) there should be a roll num in Students. Anyone who can help in this regard

推荐答案

如果存在参照约束,请确保Enroll中的每个rollno也必须出现在Student中,那么您对最小和最大的8分答案都是正确的.这个问题实际上并没有提到任何这样的约束.无需仅仅因为rollno属性出现在两个表中就假设存在RI约束.因此,最佳答案是最小0和最大8.如果这是一个选择题,而0,8不是给出的答案之一,则回答8,8-然后告诉您的老师,这个问题不清楚.

If there was a referential constraint in place ensuring that every rollno in Enroll must also appear in Student then your answer of 8 for both minimum and maximum would be correct. The question doesn't actually mention any such constraint however. There's no need to assume that the RI constraint exists just because the rollno attribute appears in both tables. So the best answer is 0 minimum and 8 maximum. If it's a multiple-choice question and 0,8 isn't one of the given answers then answer 8,8 instead - and tell your teacher that the question is unclear.

这篇关于自然连接中元组的最大和最小数目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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