wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

12B revew midterms

Total questions: 17

Worksheet time: 16mins

Name
Class
Date
1.

What does ERD stand for in database design?

a)

Entity Relationship Data

b)

Entity Relationship Diagram

c)

Entity Reference Diagram

d)

Enhanced Relational Database

2.

In an ERD, what do rectangles represent?

a)

Relationships

b)

Attributes

c)

Entities

d)

Primary Keys

3.

What is the purpose of a primary key in a database table?

a)

To link tables together

b)

To allow duplicate values in a table

c)

To uniquely identify each record

d)

To store large amounts of text

4.

Which SQL command is used to create a new table in SQLite?

a)

INSERT INTO

b)

CREATE TABLE

c)

NEW TABLE

d)

ADD TABLE

5.

What type of relationship exists when one record in Table A relates to many records in Table B?

a)

One-to-One

b)

One-to-Many

c)

Many-to-Many

d)

None of the above

6.

What is the SQL syntax to define a foreign key in SQLite?

a)

FOREIGN KEY (column_name) REFERENCES table_name(column_name)

b)

SET FOREIGN KEY (column_name) IN table_name(column_name)

c)

ADD FOREIGN KEY (column_name) TO table_name(column_name)

d)

LINK FOREIGN KEY (column_name) WITH table_name(column_name)

7.

Which of the following best describes a one-to-one relationship?

a)

One student can enroll in multiple courses

b)

A country has multiple cities

c)

Each passport belongs to exactly one person

d)

A book can be borrowed by multiple students

8.

In an ERD, what symbol is typically used to represent a many-to-many relationship?

a)

A solid line

b)

A crow’s foot

c)

A double circle

d)

A triangle

9.

What happens if you try to insert a duplicate value into a primary key column?

a)

SQLite will allow it

b)

SQLite will generate a warning but insert the data

c)

SQLite will reject the insertion with an error

d)

SQLite will replace the existing record

10.

What are the three main components of an ERD?

a)
Classes, Methods, Objects
b)
Tables, Columns, Rows
c)
Nodes, Edges, Weights
d)
Entities, Relationships, Attributes
11.

Describe the difference between a primary key and a foreign key.

a)
A primary key can be duplicated across tables, while a foreign key cannot.
b)
A primary key uniquely identifies a record in a table, while a foreign key links to a primary key in another table.
c)
A primary key is always a string, while a foreign key is always an integer.
d)
A primary key is used for indexing, while a foreign key is used for sorting records.
12.

Write an SQL statement to create a Students table with the following fields: id (primary key), name, and age.

a)
CREATE TABLE Students (id INT PRIMARY KEY, name VARCHAR(255), age INT);
b)
CREATE TABLE Students (id INT, name TEXT, age INTEGER);
c)
CREATE TABLE Students (student_id INT PRIMARY KEY, full_name VARCHAR(100), years INT);
13.

Write an SQL statement to create a Courses table with course_id as the primary key and course_name as a text field.

a)
CREATE TABLE Courses (course_id SERIAL PRIMARY KEY, course_name STRING);
b)
CREATE TABLE Courses (course_id INT, course_name VARCHAR);
c)
CREATE TABLE Courses (course_id INT PRIMARY KEY, course_name VARCHAR(255));
d)
CREATE TABLE Courses (course_id INT PRIMARY KEY, course_name TEXT);
14.

Write an SQL statement to create an Enrollments table that links Students and Courses using foreign keys.

a)
CREATE TABLE Enrollments ( enrollment_id INT PRIMARY KEY, student_id INT, course_id INT, FOREIGN KEY (student_id) REFERENCES Students(student_id), FOREIGN KEY (course_id) REFERENCES Courses(course_id) );
b)
CREATE TABLE Enrollments (enrollment_id INT, student_id INT, course_id INT);
c)
CREATE TABLE Enrollments (enrollment_id INT PRIMARY KEY, student_id VARCHAR(255), course_id VARCHAR(255));
d)
CREATE TABLE Enrollments (enrollment_id INT PRIMARY KEY, student_id INT, course_id INT, PRIMARY KEY (course_id));
15.

How would you represent a one-to-many relationship in an ERD?

4 lines
16.

Why is it important to set NOT NULL constraints on certain columns in a table?

4 lines
17.

If you were designing an ERD for an e-commerce system, what three main entities would you include?

4 lines