Question: 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 and
;
create table Enrolments
student integer references Studentsid
course integer references Coursesid
;
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 checkquota
check not exists
select
from Courses c join Enrolments e on ecourse cid
group by estudent
having count cquota
;
b
create assertion checkquota
check not exists
select
from select cid countstudent as nstu, cquota
from Courses c join Enrolments e on ecourse cid
group by cid cquota
as x
where xnstu xquota
;
c
create assertion checkquota
check not exists
select
from Courses c
where cquota select count from Enrolments e where ecourse cid
;
d
None of the above is correc
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
