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

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

问题描述

我遇到了一个这样的问题

I came across a question that states

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

Consider the following relation schema pertaining to a students

  • 数据库:学生(rollno、姓名、地址)
  • 报名(rollno, courseno, coursename)
  • database: Student (rollno, name, address)
  • Enroll (rollno, courseno, coursename)

主键显示为下划线.元组的数量Student 和 Enroll 表分别为 120 和 8.什么是最大值和可以出现在 (Student * Enroll) 中的最小元组数,其中*"表示自然连接?

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天全站免登陆