Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following SQL schema: create table Courses ( id integer primary key, code text, title text, quota integer check ( quota between 1 and

Consider the following SQL schema:
create table Courses (
id integer primary key,
code text,
title text,
quota integer check (quota between 1 and 9999),
...
);
create table Enrolments (
student integer references Students(id),
course integer references Courses(id),
...
);
Which of the following assertions captures the requirement that the total number of students enrolled in a course cannot be greater than the course quota?
(a)
create assertion check_quota
check (not exists (
select *
from Courses c join Enrolments e on (e.course = c.id)
group by e.student
having count(*)> c.quota
)
);
(b)
create assertion check_quota
check (not exists (
select *
from (select c.id, count(student) as nstu, c.quota
from Courses c join Enrolments e on (e.course = c.id)
group by c.id, c.quota
) as x
where x.nstu > x.quota
)
);
(c)
create assertion check_quota
check (not exists (
select *
from Courses c
where c.quota >=(select count(*) from Enrolments e where e.course = c.id)
)
);
(d)
None of the above is correc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions

Question

=+13.4. 1 Relate the result in Problem 13.3 to Theorem 5.1(ii).

Answered: 1 week ago

Question

consider a warehouse with 12 10'X10' bays as show below with an I/O

Answered: 1 week ago