1) List all the possible candidate key(s) for the departments table. /2 2) If we
ID: 3888951 • Letter: 1
Question
1) List all the possible candidate key(s) for the departments table. /2
2) If we didn’t use a surrogate key for the primary key on the enrollments table, what would
you have used as a natural primary key instead and why? /4
3) We have a gender column on the students table. The type on this column is a CHAR(1), but
any single character value could be input into that field right now.
a) Name two different approaches you could use to make sure that only the ISO gender
codes (M,F,U,N) are valid values to insert into the gender column. /4
b) Write the DDL you would use to implement both of these solutions (but don’t actually
change anything in the database). /10
4) Currently in the sections table, it is possible for the num_enrolled to be higher than the max_enrollment. What could you add to make sure this doesn’t happen? Write the code that would accomplish this. /10
d INT first name VARCHAR(100) last namo VARCHARC100) email-address VARCHAR(100) major_code VARCHAR(10) gender CHAR) d INT code VARCHAR(10 name VARCHAR(100) Departments id INT code VARCHAR10) University id INT name VARCHAR100) id INT student id INT section id INT grade NUMERIC status code VARCHARO COurse desc TEXT credit units NUMERIC uriversity id INT id INT id INT section code VARCHARC100 d INT employee number INT first name VARCHAR(100) last name VARCHARC100) seniority_date DATE email address VARCHAR100) lec type VARCHAR(10) term id INT enrolled INT num num waitlisted INT instructor id INT days VARCHAR3) start time TIME end time TIME location-code VARCHAR(10) ia INT code VARCHAR10) name VARCHARI500 start date DATE end date DATEExplanation / Answer
Answer:
Q1. all the possible candidate key for the departments table are:
id INT
code VARCHAR
university_id INT
Q2. if we have not used the surrogate key then my primary key for the departments table will be id. Because for every student, there will be a unique id and for every department, there will also be a unique id. so it is easy to know which id is of whom.
Q3. (A)
If (input = M,N,U,N)
{
printf ("Value correct");
}
else { printf ("value incorrect");}
(B) Create Gender
if ( input = M,F,U,N)
Q4. int num_enrolled, max_enrollemnt
If (int num_enrolled <= max_enrollemnt )
{
Printf ("True" );
}
else
{
printf("False");
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.