从我的模式中检索正确的数据 [英] retrieve correct data from my schemas

查看:35
本文介绍了从我的模式中检索正确的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检索教授超过 1 门课程的教师姓名

I would like to retrieve the Names of teachers who teach more than 1 course

我真的被困在如何做这件事上,我所知道的是我需要考虑课程模式并对其进行操作,我可以在 pi(投影),sigma(条件),rho(重命名)等(不是我任何特定的数据库语言)?

I am really stuck on how to do it , all I know is that I need to consider the Course schema and operate on it , could I get some advice in terms of pi(projection),sigma(condition),rho(rename) etc (not i any specific database language)?

推荐答案

既然是作业,基本上需要阅读 &通过教科书的绝对介绍性文本工作关系模型基础知识练习关系代数,我会根据你的作业给出一些指导性问题.

Since this is homework and you basically need to read & work through a textbook's absolutely introductory text & exercises on relational model basics & the relational algebra, I give some guiding questions tailored to your assignment.

关系(给定或查询结果)带有谓词,即由属性参数化的语句模板.一个关系包含从它的谓词中做出真陈述的元组.PK &查询不需要 FK.

A relation (given or query result) comes with a predicate, ie a statement template parameterized by attributes. A relation holds the tuples that make a true statement from its predicate. PKs & FKs are not needed for querying.

元组的关系表达式是什么,其中...

What is a relation expression for the tuples where...

teacherid 标识的人教授由cid标识的课程,名为name?(答案:课程.)
teacheridcid名为name?(相同的答案.为什么?)
teacheridcid 并且 cid 被命名为 name?(相同的答案.为什么?)

the person identified by teacherid teaches the course identified by cid, which is named name? (Answer: Course.)
teacherid teaches cid named name? (Same answer. Why?)
teacherid teaches cid AND cid is named name? (Same answer. Why?)

(我们可以从您的作业查询中推断出课程和教师谓词指的是人,或者您无法获得教师姓名.)

(We can infer from your assignment query that the Course & Teacher predicates refer to persons or you couldn't get at teacher names.)

tc 名为 n?
tc 名为 n AND c = 101?
tc名为nt占据o?

t teaches c named n?
t teaches c named n AND c = 101?
t teaches c named n AND t occupies o?

t 教授一些名为某个名字的课程?
对于某些ctc 命名一些名称?(相同的答案.为什么?)
对于某些 ctc 命名的东西 AND c = 101?(为什么我们需要一些?)

t teaches some course named some name?
for some c, t teaches c named some name? (Same answer. Why?)
for some c, t teaches c named something AND c = 101? (Why do we need FOR SOME?)

i ID 是学生,并且不 i 参加某位老师教授的课程?
一些学生参加了t 教授的课程,或者t 占用了一些办公室?

i ids a student AND NOT i takes some course taught by some teacher?
some student takes some course taught by t OR t occupies some office?

因此:我们使用逻辑运算符和给定的谓词为我们想要的元组组成一个查询谓词.然后我们得到一个表达式,通过将逻辑运算符转换为关系运算符并将给定的谓词转换为给定的关系来计算它们.(为了使用 AND NOT (MINUS) 或 OR (UNION) 来获得两个具有相同属性的关系可能会很繁琐.)

Thus: We compose a query predicate for the tuples we want using logic operators and the given predicates. Then we get an expression that calculates them by converting logic operators to relation operators and given predicates to given relations. (It can be tedious rearranging to get two relations with the same attributes in order to use AND NOT (MINUS) or OR (UNION).)

参见这个.

检索教授超过 1 门课程的教师姓名

retrieve the Names of teachers who teach more than 1 course

您需要元组,其中属性 Name 是一个人的姓名,并且对于某些两个值,该人教授第一个课程,他们教授第二个课程,并且这些值/课程不相同.

You want tuples where attribute Name is the name of a person and for some two values the person teaches the first one's course and they teach the second one's course and those values/courses are not the same.

这篇关于从我的模式中检索正确的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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