Font size
WorksheetsSQL.
Total questions: 84
Worksheet time: 42mins
The Books table has the following columns: ISBN - unique code of the book edition, title of the book, author of the book, number of pages. Which of these columns can be the Primary key?
ISBN
author
pages
title
Select the Primary key from the following description: Groups (group_id, name, email)
name
group_id
name, group_id
Select the Primary key from the following description: Teachers (teacher_id, lastname, email)
teacher_id
Teachers
lastname
Select the Primary key from the following description: Schedule (schedule_id, course_id, teacher_id, group_id, time, room)
schedule_id
course_id
teacher_id
group_id
The database has a Courses table with the following columns: course id, course name, number of credits. Select which of the following constraints can be implemented for this table?
the number of credits can be from 1 to 6
books for each course should be available in the university library
course grades must range from 0 to 100%
courses must last 3 months
The database has a Schedule table with the following columns: schedule_id, course_id, teacher_id, group_id, time, room, day_of_week. Select which of the following constraints can be implemented for this table?
lesson time can be from 08:00 to 22:00
lessons should be interesting
students must attend all lessons
after each lesson, students must complete homework
The database has a Schedule table with the following columns: schedule_id, course_id, teacher_id, group_id, time, room, day_of_week. Select the possible query for this table.
show group lessons by its id
show how well students understand
the lesson material
show student marks by student_id
show which course students like the most
The database has a Courses table with the following columns: course id, course name, number of credits. Select the possible query for this table.
show the number of credits by course name
show course description by course name
show the most interesting courses
show a course with a lot of homework
A teacher teaches one or more groups, each of which is taught by one or more teachers. The TEACHERS table has teacher_id, teacher_name columns. The GROUPS table has group_id, name columns. Identify a table with a Foreign Key(s) for the relationship between TEACHERS and GROUPS tables.
TEACHERS
GROUPS
in the TEACHERS table or in the GROUPS table - both options are correct
associative table between TEACHERS and GROUPS tables
A teacher may be assigned with exactly one position. A position must be assigned to one or many teachers. The TEACHERS table has teacher_id, teacher_name, birthdate columns. The POSITIONS table has position_id, position_name columns. Identify a type of the relationship between TEACHERS and POSITIONS entities.
many (teachers)-to-many (positions)
one (positions)-to-many (teachers)
one (teachers)-to-many (positions)
one (teachers)-to-one (positions)
A teacher may be assigned with exactly one position. A position must be assigned to one or more teachers. The TEACHERS table has teacher_id, teacher_name, birthdate columns. The POSITIONS table has position_id, position_name columns. Identify a table with a Foreign Key(s) for the relationship between TEACHERS and POSITIONS tables.
in the TEACHERS table or in the POSITIONS table - both options are correct
associative table between TEACHERS and POSITIONS tables
TEACHERS
POSITIONS
A teacher teaches one or more groups, each of which is taught by one or more teachers. The TEACHERS table has teacher_id, teacher_name columns. The GROUPS table has group_id, name columns. Identify a type of the relationship between TEACHERS and GROUPS tables.
one (groups)-to-many (teachers)
one (teachers)-to-one (groups)
one (teachers)-to-many (groups)
many (teachers)-to-many (groups)
A teacher teaches one or more subjects, each of which is taught by one or more teachers. Definitions of the entities are: Teachers (teacher_id, name, birthdate), Subjects (subject_id, name, description). Identify a type of the relationship between TEACHERS and SUBJECTS tables.
many (teachers)-to-many (subjects)
one (subjects)-to-many (teachers)
one (teachers)-to-many (subjects)
one (teachers)-to-one (subjects)
A teacher teaches one or more subjects, each of which is taught by one or more teachers. Definitions of entities are: Teachers (teacher_id, name, birthdate), Subjects (subject_id, name, description). Identify a table with a Foreign Key(s) for the relationship between TEACHERS and SUBJECTS tables.
in the Teachers table or in the Subjects table - both options are correct
Subjects
Teachers
associative table between Teachers and Subjects tables
Entities Groups and Subjects have a many-to-many relationship type. For this reason a new associative table between them should be created - Schedule table. Definitions of tables are: Groups (group_code (PK), group_name), Subjects (subject_code (PK), subject_name, description). Identify attributes in the Schedule table.
schedule_id (PK), group_code (FK), subject_code (FK)
schedule_id (PK), subject_name (FK)
schedule_id (PK), group_code (FK)
schedule_id (PK), group_name (FK), subject_name (FK)
Determine the relationship type between Courses and Teachers entities by the description: "One course can be taught by many teachers, and one teacher can teach many courses".
none of the given
one-to-one
many-to-many
one-to-many
Determine the relationship type between Students and Groups entities by the description: "One student can be enrolled only in one group, and one group contains many students".
none of the given
one-to-one
one-to-many
many-to-many
Determine the relationship type between Students and Readers entities by the description: "One student has only one reader's card, and one reader's card can belong to only one student".
none of the given
many-to-many
one-to-one
one-to-many
In an ER-diagram an entity is represent by a
ellipse
rectangle
rhombus
circle
Select the functional dependency according to the table description: Teachers (teacher_id, last_name, department_id)
none of the given
full
transitive
partial
Select the functional dependency according to the table description: Courses (course_id, course_name, credits)
transitive
none of the given
partial
full
Select the Normal Form by the table description: Teachers (teacher_id, last_name, department_id)
2
3
1
0
Select the Normal Form by the table description: Courses (course_id, major_id, course_name, credits, major_name)
0
3
2
1
Select the Normal Form by the table description: Groups (group_id, group_name, adviser_id, adviser_last_name)
1
0
2
3
Select the Normal Form by the table description: Students (stud_id, last_name, subject_ids)
0
1
2
3
Select the functional dependency according to the table description: Students (stud_id, last_name, group_id)
partial
full
transitive
none of the given
Answer if the next table has a partial dependency: Courses (course_id, major_id, course_name, credits, major_name)
no
yes
Answer if the next table has a partial dependency: Teachers (teacher_id, last_name, department_id)
yes
no
Answer if the next table has a partial dependency: Schedule (teacher_id, group_id, course_id, time, room)
yes
no
Complete the code to create the table Teachers (teach_id, last_name, depart_id (FK)): CREATE TABLE Teachers teach_id int PRIMARY KEY, last_name varchar(20), depart_id int, _______ (depart_id) REFERENCES Departments(depart_id));
FOREIGN KEY
FOREIGN
PRIMARY KEY
KEY
Complete the code to drop the table Courses:
REMOVE TABLE
DELETE TABLE
DROP COLUMN
DROP TABLE
Complete the code to create the table Departments (dep_id, dep_name): CREATE TABLE Departments dep_id int _______, dep_name varchar(15));
PRIMARY KEY
KEY
FOREIGN KEY
PRIMARY
Complete the code to create the table Students (stud_id, last_name): CREATE TABLE Students stud_id int, last_name varchar(20), ________ (stud_id));
KEY
PRIMARY KEY
FOREIGN KEY
PRIMARY
Complete the code to create the table Groups (group_id, group_name): ________ Groups (group_id int PRIMARY KEY, group_name varchar(20));
CREATE
CREATE TABLE
TABLE
ALTER TABLE
The SQL command which allows to change the structure of a table is
ALTER DATABASE
DROP TABLE
ALTER TABLE
CREATE TABLE
Which of the following SQL statements can be used to create a table?
CREATE TABLE
ALTER TABLE
CREATE DATABASE
ADD TABLE
Complete the code to create the table Courses (course id, name): CREATE TABLE Courses( course_id int _______, name varchar(10));
PRIMARY KEY
KEY
PRIMARY
FOREIGN KEY
Complete the code to create the table Departments (dep_ id, name, faculty_id), where faculty_id is a FK to the table Faculties: CREATE TABLE Departments (dep_id int PRIMARY KEY, name varchar(10), faculty_id int, ________ (faculty_id) REFERENCES Faculties(faculty_id));
FOREIGN KEY
PRIMARY KEY
REFERENCES
FOREIGN
Complete the code to create the table Departments (dep id, dep_name), where dep_name attribute has the not null constraint: CREATE TABLE Departments (dep_id int PRIMARY KEY, dep_name varchar(10) IS ________));
NOT NULL
UNIQUE
NULL
PRIMARY KEY
Complete the code for the following table Subjects (subj_id (PK), name, credits): UPDATE Subjects SET credits=5 _______ credits=3;
WHERE
WHEN
IF
WITH
Complete the code for the following table Subjects (subj_id (PK), name, credits): _______ SET credits=credits+1;
UPDATE Subjects
ALTER TABLE Subjects
Subjects
UPDATE
Complete the code for the following table Faculties(facult_id (PK), name): DELETE FROM Faculties ______ facult_id=1;
WHEN
SET
WITH
WHERE
Complete the code for the following table Groups(group_id (PK), name): ______ SET name='Database Design' WHERE group_id=1;
ALTER TABLE Groups
Groups
UPDATE
UPDATE Groups
Complete the code for the following table Groups(group_id (PK), name): DELETE FROM Groups _____ group_id=1;
DROP
WHEN
WITH
WHERE
Complete the code for the following table Students(stud_id (PK), lastname): DELETE FROM Students WHERE _____= 1;
id
stud_id
student_number
PK
Complete the code: _____ Students VALUES (1,'FirstName1','LastName1','2000-01-01'1);
INSERT INTO
DELETE FROM
CREATE TABLE
UPDATE
Complete the code: DELETE FROM Students ______ stud_id=2;
WHERE
AND
WHEN
WITH
Complete the code for the following table Departments(dep_id(PK), name): UPDATE Departments _____ name='IT' WHERE depart_id=1;
SET
FOR
WHERE
GET
Complete the code for the following table Faculties(facult_id (PK), name): ______ Faculties SET name='Information Technology' WHERE name='IT';
ALTER TABLE
UPDATE
CHANGE
UPDATE Faculties
Rows are also called records
True
False
Primary key must contain unique values
True
False
What is Subject Area Analysis?
Subject area analysis determines initial functionality requirements and defines project boundaries.
Subject area analysis allows you to identify essence of project.
Subject area analysis defines information in the future project.
All answers are correct.
Database is an organized collection of data, stored and accessed electronically.
True
False
Tables are also called relations
True
False
The database has a Students table with the following columns: student_id, first_name, last_name, iin, email, phone_number. Select which of the following constraints cannot be implemented for this table?
IIN must be unique
first name cannot be empty
number of symbols of phone number must be 11
student must have excellent grades
Primary key can be empty
True
False
Rows are also called tuples
True
False
Primary key is a column in a table which uniquely identifies each row in a table
True
False
Columns are also called attributes
True
False
What is Relational database?
Define incorrect answer.
Relational database is a database based on the relational model of data
Relational database is a database that does not use tables and attributes
Relational model organizes data into tables of columns and rows, with a unique key (or Primary key) identifying each row
Relational database is a database proposed by E.F. Codd in 1970
The University database contains Teachers and Advisors tables. Usually teachers and advisors are different people, but some of them may hold 2 positions and, as a result, will be recorded in both tables. The Teachers table contains teach_id (PK), last_name, first_name attributes, while the Advisors table contains adv_id (PK), last_name, first name attributes. Which operator (command) can be used to obtain a list of only teachers - excluding those people who occupy 2 positions at the same time?
INTERSECT
UNION
EXCEPT
Complete the code to get all columns from the table: SELECT ___ FROM Groups;
*
ALL COLUMNS
group_id
ALL
The University database contains Teachers and Advisors tables. Usually teachers and advisors are different people, but some of them may hold 2 positions and, as a result, will be recorded in both tables. The Teachers table contains teach_id (PK), last_name, first_name attributes, while the Advisors table contains adv_id (PK), last_name, first_name attributes. Which operator (command) can be used to obtain a list of only those people who occupy 2 positions at the same time?
UNION
INTERSECT
EXCEPT
The University database contains Students and Groups tables. The Students table contains stud_id (PK), first_name, last_name, group_id (FK to the Groups table). The Groups table contains group_id (PK), name. Which of the following commands will list the names of students and the names of their groups? Only those students who are already enrolled in groups should be included in the list.
RIGHT JOIN
INNER JOIN
FULL JOIN
LEFT JOIN
The University database contains Teachers and Advisors tables. Usually teachers and advisors are different people, but some of them may hold 2 positions and, as a result, will be recorded in both tables. The Teachers table contains teach_id (PK), last_name, first_name attributes, while the Advisors table contains adv_id (PK), last_name, first_name attributes. Which operator (command) can be used to obtain a general list of all teachers and advisors (in the form of a table with 2 columns first_name and last_name) ?
UNION
INTERSECT
EXCEPT
Complete the code to get all columns from the table: SELECT _____ FROM Departments;
ALL COLUMNS
ALL
*
department_id
Aggregate function ... selects the average value.
avg()
sum()
count()
average()
Aggregate function ... selects the minimum value.
minimum()
min()
small()
least()
The ... clause divides the rows returned from the SELECT statement into groups. Then for each group, you can apply an aggregate function.
HAVING
GROUP BY
WHERE
ORDER BY
The ... clause allows to sort rows by returned from a SELECT statement in ascending or descending order based on the specified criteria.
ORDER BY
HAVING
GROUP BY
ORDER WITH
Aggregate function ... selects the maximum value
peak()
high()
maximum()
max()
Aggregate function ... selects the number of occurrences (the number of tuples that satisfy a selection condition).
amount()
sum()
count()
number()
The ... operator compares the value of attribute to each value returned by the subquery. This keyword (which must follow a comparison operator) returns TRUE if the comparison is TRUE for any of the values in the column that the subquery returns.
EXISTS
ANY
AT LEAST
ALL
Write the possible operator when a result of a subquery is multiple values (multiple fields).
none of the given
=
<>
IN
SELECT SQL statement(s) with which subqueries can be used.
only with INSERT
only with UPDATE and DELETE
only with SELECT
all of the given
The ... operator (which must follow a comparison operator) compares the value of attribute to every value returned by the subquery. The result is true if all rows yield true. The result is false if any false result is found.
EXISTS
ALL
ANY
EVERY
Select the condition when the «=» operator can be used with a subquery.
the result of the subquery is one value (one field)
the subquery contains the GROUP BY keyword
the result of the subquery is multiple values (multiple fields)
none of the given
SQL allows testing the emptiness of a subquery's result using the ... keyword.
IS NULL
ANY
ALL
EXISTS
Can the SELECT statement on which the view is based contain a join operation?
yes
no
If the records in the physical table have changed, will the view show the updated records?
yes
no
What statement is used to create a view?
ADD VIEW
NEW VIEW
CREATE TABLE
CREATE VIEW
Which statement can be used to slightly change the structure of a view?
ALTER TABLE
CREATE OR REPLACE VIEW
ALTER VIEW
CHANGE VIEW
What statement can be used to show rows from a view?
CHOOSE
SHOW
CREATE TABLE
SELECT
What keyword is used to create а СТЕ?
BY
СТЕ
WITH
USING
