Foreign Keys and Referential Integrity
- 58Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is a foreign key in a relational database?
What is a foreign key in a relational database?
58 questions
- 1
What is a foreign key in a relational database?
- A
A derived value used to calculate attributes in another relation
- B
A single attribute used to sort tuples within a relation
- C
A group of attributes used to guarantee uniqueness within one relation
- D
A group of attributes used to refer to tuples in another relation
Correct answer
DA group of attributes used to refer to tuples in another relation
Explanation
A foreign key is an attribute or group of attributes used to refer to tuples in another relation.
- A
- 2
What does a referential integrity constraint prevent?
- A
Attributes from having values of different data types
- B
References from pointing to nonexistent tuples
- C
Relations from containing more than one candidate key
- D
Tuples from containing null values in every column
Correct answer
BReferences from pointing to nonexistent tuples
Explanation
Referential integrity requires a reference to point to an existing tuple rather than becoming a dangling reference.
- A
- 3
How are keys conventionally represented in a relational schema?
- A
The key attributes are placed in parentheses
- B
The key attributes are written in boldface
- C
The key attributes are written in lowercase
- D
The key attributes are underlined
Correct answer
DThe key attributes are underlined
Explanation
Underlining an attribute or group of attributes in a relational schema indicates that it is a key.
- A
- 4
Why is roll number a key for the Student relation?
- A
It uniquely identifies each student tuple
- B
It identifies the department offering a course
- C
It identifies the degree program of a student
- D
It identifies the professor advising a student
Correct answer
AIt uniquely identifies each student tuple
Explanation
The value of roll number can be used to uniquely identify a particular row or tuple in the Student relation.
- A
- 5
What does the advisor attribute in the Student relation represent?
- A
The department ID of the student's academic department
- B
The course ID of the student's current course
- C
The employee ID of the student's faculty advisor
- D
The roll number of the student's department head
Correct answer
CThe employee ID of the student's faculty advisor
Explanation
Advisor stores the employee ID of the faculty member identified as the student's advisor.
- A
- 6
What is required of the advisor value for a student in the example database?
- A
It must identify the student's degree string
- B
It must identify the student's department name
- C
It must identify a faculty member's employee ID
- D
It must identify the student's current course ID
Correct answer
CIt must identify a faculty member's employee ID
Explanation
All students are required to have an advisor, and the advisor value comes from the employee ID domain of faculty members.
- A
- 7
If more information about a student's advisor is needed, what should be done?
- A
Use the student's roll number as the advisor identifier
- B
Search for the advisor's name in the enrollment relation
- C
Look up the advisor in the appropriate related relation
- D
Infer the information from the student's degree value
Correct answer
CLook up the advisor in the appropriate related relation
Explanation
The advisor attribute identifies the faculty member, while additional details must be obtained from the appropriate relation, such as Professor.
- A
- 8
Which attribute identifies a department in the Department relation?
- A
Department ID
- B
Department name
- C
Department HOD
- D
Department phone
Correct answer
ADepartment ID
Explanation
Department ID is used as the key to identify departments, even though the name could also serve as a key in the example.
- A
- 9
What does the HOD attribute in the Department relation identify?
- A
The numerical identifier assigned to the department
- B
The degree program offered by the department
- C
The faculty member responsible for heading the department
- D
The office phone number assigned to the department
Correct answer
CThe faculty member responsible for heading the department
Explanation
HOD identifies the faculty member who is academically responsible for running the department.
- A
- 10
Which attribute serves as the key for the Professor relation?
- A
Employee ID
- B
Department number
- C
Professor name
- D
Start year
Correct answer
AEmployee ID
Explanation
Employee ID identifies professors in the Professor relation.
- A
- 11
What does start year represent in the Professor relation?
- A
The year the faculty member completed a degree
- B
The year the faculty member became a department head
- C
The year the faculty member joined the department
- D
The year the faculty member first taught a course
Correct answer
CThe year the faculty member joined the department
Explanation
Start year records the year in which the faculty member joined the particular department.
- A
- 12
What does the department number in the Professor relation indicate?
- A
The department in which the professor is employed
- B
The number of courses taught by the professor's department
- C
The department in which the professor earned a degree
- D
The order in which the professor joined the institute
Correct answer
AThe department in which the professor is employed
Explanation
All faculty members work in departments, and this attribute identifies the professor's department.
- A
- 13
Which attribute acts as the key for the Course relation?
- A
Course ID
- B
Course name
- C
Department number
- D
Credits
Correct answer
ACourse ID
Explanation
Course ID is used to identify courses and serves as the key for the Course relation.
- A
- 14
What does the credits attribute of a course indicate?
- A
The number of students permitted to enroll in the course
- B
The number of professors assigned to teach the course
- C
The number of semesters required to teach the course
- D
The number of credits earned upon completing the course
Correct answer
DThe number of credits earned upon completing the course
Explanation
Credits records the number of credits earned when the course is completed.
- A
- 15
What does the department number in the Course relation identify?
- A
The department that offers the course
- B
The department that created the course prerequisite
- C
The department in which every student must enroll
- D
The department that employs every course instructor
Correct answer
AThe department that offers the course
Explanation
The department number indicates which department offers the course.
- A
- 16
Why does the Enrollment relation require a composite key containing roll number, course ID, semester, and year?
- A
A student may take several courses and a course may recur across offerings
- B
Each student can have only one course and one grade overall
- C
Each course ID independently identifies every enrollment tuple
- D
Semester and year identify students independently of their courses
Correct answer
AA student may take several courses and a course may recur across offerings
Explanation
A student can take several courses, and the same course can be offered in different semesters and years, so all four attributes are needed to identify an enrollment.
- A
- 17
What values can the semester attribute take in the example database?
- A
Odd for January and even for August
- B
Summer for August and winter for January
- C
Fall for August and spring for January
- D
Odd for August and even for January
Correct answer
DOdd for August and even for January
Explanation
The example uses odd for the August semester and even for the January semester.
- A
- 18
What value does grade have for an enrollment in the current semester?
- A
The student's previous grade
- B
Null
- C
The course's credit value
- D
Zero
Correct answer
BNull
Explanation
The grade is null during the current semester and receives an appropriate value after the semester ends.
- A
- 19
What information does the Enrollment relation capture?
- A
Departments offering courses and assigning phone numbers
- B
Courses requiring prerequisites and changing names
- C
Professors joining departments and receiving salaries
- D
Students taking courses and receiving grades
Correct answer
DStudents taking courses and receiving grades
Explanation
Enrollment records how students enroll in courses and the grades associated with those enrollments.
- A
- 20
What does a tuple in the Teaching relation represent?
- A
A professor teaching a course in a particular semester and year
- B
A department offering a degree in a particular semester and year
- C
A course requiring another course in a particular semester and year
- D
A student completing a course in a particular semester and year
Correct answer
AA professor teaching a course in a particular semester and year
Explanation
Teaching records which employee teaches which course in a specified semester and year, along with the classroom information.
- A
- 21
Why are all the attributes of a Teaching tuple needed for its key in the example?
- A
Every professor teaches exactly one course during employment
- B
No proper subset uniquely identifies a course-teaching assignment
- C
Semester and year alone identify every teaching assignment
- D
Every course is taught by exactly one professor in all years
Correct answer
BNo proper subset uniquely identifies a course-teaching assignment
Explanation
An employee can teach several courses, a course can have several professors, and offerings recur by semester and year, so no subset is sufficient.
- A
- 22
If a tuple (C1,C2) appears in the Prerequisite relation, what does it mean?
- A
C2 must be successfully completed before enrolling in C1
- B
C1 and C2 must be taught by the same professor
- C
C1 must be successfully completed before enrolling in C2
- D
C1 and C2 must be taken during the same semester
Correct answer
CC1 must be successfully completed before enrolling in C2
Explanation
The first course, C1, is the prerequisite for the second course, C2.
- A
- 23
In the example, what relationship does a Data Structures course have to a Database Systems course?
- A
The two courses are alternative names for one course
- B
The two courses must always be taken in the same semester
- C
Database Systems is a prerequisite for Data Structures
- D
Data Structures is a prerequisite for Database Systems
Correct answer
DData Structures is a prerequisite for Database Systems
Explanation
The example states that Data Structures should be completed before taking Database Systems.
- A
- 24
Which attribute is a foreign key in the Department relation?
- A
HOD, referencing Professor employee ID
- B
Name, referencing Student roll number
- C
Phone, referencing Course ID
- D
Department ID, referencing Enrollment grade
Correct answer
AHOD, referencing Professor employee ID
Explanation
The HOD attribute stores a professor's employee ID and therefore references the Professor relation.
- A
- 25
Which foreign-key relationship is represented by Student.department number?
- A
It references Department.department ID
- B
It references Course.course ID
- C
It references Student.roll number
- D
It references Professor.employee ID
Correct answer
AIt references Department.department ID
Explanation
Student.department number links each student to the corresponding department ID.
- A
- 26
Which foreign-key relationship is represented by Professor.department number?
- A
It references Professor.employee ID
- B
It references Course.course ID
- C
It references Department.department ID
- D
It references Student.roll number
Correct answer
CIt references Department.department ID
Explanation
The department number in Professor references the department ID of the Department relation.
- A
- 27
Which foreign-key relationship is represented by Student.advisor?
- A
It references Enrollment.roll number
- B
It references Professor.employee ID
- C
It references Course.course ID
- D
It references Department.department ID
Correct answer
BIt references Professor.employee ID
Explanation
Advisor stores a faculty member's employee ID and references the Professor relation.
- A
- 28
Which foreign-key relationship is represented by Enrollment.roll number?
- A
It references Professor.employee ID
- B
It references Course.course ID
- C
It references Student.roll number
- D
It references Department.department ID
Correct answer
CIt references Student.roll number
Explanation
Enrollment.roll number identifies the student associated with an enrollment and references Student.
- A
- 29
Which foreign-key relationship is represented by Enrollment.course ID?
- A
It references Course.course ID
- B
It references Student.roll number
- C
It references Department.department ID
- D
It references Professor.employee ID
Correct answer
AIt references Course.course ID
Explanation
Enrollment.course ID identifies the course associated with an enrollment and references Course.
- A
- 30
Which statement correctly describes foreign-key naming?
- A
A foreign key must always have exactly the referenced key's name
- B
A foreign key may have a different name from the referenced key
- C
A foreign key cannot reference a primary key with another name
- D
A foreign key must always be a single attribute
Correct answer
BA foreign key may have a different name from the referenced key
Explanation
Names such as department number and department ID may differ even though they represent the same referenced concept.
- A
- 31
How can ambiguous attribute names be disambiguated when the same name occurs in multiple relations?
- A
Use dot notation such as Course.course ID
- B
Use only the attribute name without its relation
- C
Replace every repeated attribute name with a key symbol
- D
Place the repeated attribute name in quotation marks
Correct answer
AUse dot notation such as Course.course ID
Explanation
Dot notation specifies the relation and attribute, such as Course.course ID, to remove ambiguity.
- A
- 32
What is a relational schema diagram used to show?
- A
Only the physical storage locations of relation tuples
- B
Only the SQL commands used to create each relation
- C
Relations, attributes, keys, and foreign-key references
- D
Only the number of rows currently stored in each relation
Correct answer
CRelations, attributes, keys, and foreign-key references
Explanation
A relational schema diagram displays relation names, attributes, underlined keys, and arrows showing foreign-key references.
- A
- 33
What does relational algebra consist of?
- A
Commands that take individual values as inputs and return programs
- B
Procedures that take database users as inputs and return permissions
- C
Rules that take SQL keywords as inputs and return physical files
- D
Operators that take relations as inputs and return new relations
Correct answer
DOperators that take relations as inputs and return new relations
Explanation
Relational algebra is a set of unary and binary operators that operate on relations and produce new relations.
- A
- 34
What is a database query in the context of this material?
- A
A request to underline the keys in a relational schema
- B
A request to change the physical location of a database file
- C
A request to define the employee ID of a professor
- D
A request to retrieve specified data from the database
Correct answer
DA request to retrieve specified data from the database
Explanation
A query is a data retrieval request specifying the information wanted from the database.
- A
- 35
Why is relational algebra described as procedural?
- A
It requires users to write a program in a general-purpose language
- B
It specifies the sequence of operations used to obtain the result
- C
It can be applied only to relations stored in procedural databases
- D
It specifies only the desired result without describing operations
Correct answer
BIt specifies the sequence of operations used to obtain the result
Explanation
Relational algebra describes what operations to perform and how to combine their results.
- A
- 36
How can a relational algebra expression be conceptually represented?
- A
As a list containing only the final relation's attributes
- B
As a tree with intermediate results flowing toward the root
- C
As a single key pointing directly to every database tuple
- D
As a diagram showing only foreign-key arrows
Correct answer
BAs a tree with intermediate results flowing toward the root
Explanation
An algebraic expression can be viewed as a tree in which information flows through operations toward the final output at the root.
- A
- 37
What role does relational algebra play in a relational query engine?
- A
It stores all relation tuples independently of the database engine
- B
It prevents SQL queries from being translated into internal expressions
- C
It provides operators that the engine can implement and optimize
- D
It replaces every relation key with a procedural variable
Correct answer
CIt provides operators that the engine can implement and optimize
Explanation
The relational query engine uses relational algebra operators and can optimize how those operators are executed.
- A
- 38
How is SQL characterized in the material?
- A
As a largely declarative way to specify queries
- B
As a notation used only to identify foreign keys
- C
As a physical storage language for relation tuples
- D
As a purely procedural sequence of relational operators
Correct answer
AAs a largely declarative way to specify queries
Explanation
SQL is described as a largely declarative query language whose requests are internally translated into relational algebra expressions.
- A
- 39
Why can translating SQL queries into relational algebra expressions support optimization?
- A
The translation guarantees that every query returns all database tuples
- B
The translation converts every query into a foreign-key constraint
- C
The algebraic expression can be rewritten into a more efficient execution plan
- D
The translation removes the need to identify relation keys
Correct answer
CThe algebraic expression can be rewritten into a more efficient execution plan
Explanation
Relational algebra expressions can be rewritten or rearranged so that the query is executed more efficiently.
- A
- 40
Which pair consists only of unary relational algebra operators?
- A
Difference and join
- B
Union and intersection
- C
Select and project
- D
Cross product and union
Correct answer
CSelect and project
Explanation
Select and project each operate on one relation, so they are unary operators.
- A
- 41
What does the select operator do?
- A
It removes every tuple containing a repeated attribute value
- B
It combines tuples from two relations into one relation
- C
It returns only selected attributes from every tuple
- D
It returns tuples satisfying a specified condition
Correct answer
DIt returns tuples satisfying a specified condition
Explanation
Selection chooses rows or tuples that satisfy a given selection condition.
- A
- 42
What is the schema of a relation produced by selection?
- A
A schema containing one attribute for every selected tuple
- B
The schema of the relation referenced by a foreign key
- C
Only the attributes mentioned in the condition
- D
The same schema as the input relation
Correct answer
DThe same schema as the input relation
Explanation
Selection filters tuples but retains the same attributes, order, and overall schema as the input relation.
- A
- 43
What does the expression c3_{\theta}(R) return?
- A
All attributes in R that appear in condition θ
- B
All tuples in R that satisfy condition θ
- C
All distinct values appearing in the key of R
- D
All tuples in another relation referenced by R
Correct answer
BAll tuples in R that satisfy condition θ
Explanation
The selection operator σθ applies condition θ to relation R and returns the satisfying tuples.
- A
- 44
Why are successive selection operations commutative?
- A
Selection changes the attributes before applying the next condition
- B
Both orders return tuples satisfying both conditions
- C
Both orders always produce different relation schemas
- D
Selection can be applied only once to any relation
Correct answer
BBoth orders return tuples satisfying both conditions
Explanation
The expressions σc1(σc2(R)) and σc2(σc1(R)) both retain exactly the tuples satisfying both conditions.
- A
- 45
Which is a valid basic selection condition?
- A
Comparing a relation name with a foreign-key arrow
- B
Comparing a tuple count with an unrelated attribute name
- C
Comparing two relation schemas without referencing attributes
- D
Comparing an attribute with another attribute or an appropriate constant
Correct answer
DComparing an attribute with another attribute or an appropriate constant
Explanation
A basic condition compares two attributes or compares an attribute with a constant of an appropriate type.
- A
- 46
How is a composite selection condition formed?
- A
By replacing every condition with a foreign-key constraint
- B
By combining only conditions that compare relation names
- C
By combining basic conditions with AND, OR, or NOT
- D
By projecting the attributes used in several relations
Correct answer
CBy combining basic conditions with AND, OR, or NOT
Explanation
Basic Boolean conditions can be combined using AND, OR, and NOT to form composite conditions.
- A
- 47
Which comparison operators are available for selection conditions?
- A
Less than, less than or equal, greater than, greater than or equal, equal, and not equal
- B
Equal, approximately equal, and logically equivalent
- C
Only equal and not equal
- D
Only greater than and less than
Correct answer
ALess than, less than or equal, greater than, greater than or equal, equal, and not equal
Explanation
The six comparison operators listed are less than, less than or equal, greater than, greater than or equal, equal, and not equal.
- A
- 48
What must generally be true of domains when ordered comparison operators are used?
- A
The domains must support a meaningful linear ordering
- B
The domains must contain exactly the same number of values
- C
The domains must contain only character strings
- D
The domains must contain only foreign-key values
Correct answer
AThe domains must support a meaningful linear ordering
Explanation
Ordered comparisons make sense when the relevant domains have an appropriate ordering relationship.
- A
- 49
Which relational algebra expression retrieves all professors named Giridhar?
- A
σname=′Giridhar′(Professor)
- B
πname=′Giridhar′(Professor)
- C
πProfessor=′Giridhar(name)
- D
σProfessor=′Giridhar′(name)
Correct answer
Aσname=′Giridhar′(Professor)
Explanation
The condition name = 'Giridhar' filters the Professor relation to tuples whose name is Giridhar.
- A
- 50
Which expression retrieves professors whose start year is between 1980 and 1985, inclusive?
- A
σstartYear=1980 OR startYear=1985(Professor)
- B
σstartYear<1980 OR startYear>1985(Professor)
- C
σstartYear≥1980 AND startYear≤1985(Professor)
- D
πstartYear≥1980 AND startYear≤1985(Professor)
Correct answer
CσstartYear≥1980 AND startYear≤1985(Professor)
Explanation
Inclusive bounds require the condition startYear≥1980 AND startYear≤1985.
- A
- 51
What does the project operator do?
- A
It changes the key values of the input relation
- B
It keeps selected attributes and discards the others
- C
It keeps selected tuples and discards the others
- D
It combines two relations using matching foreign keys
Correct answer
BIt keeps selected attributes and discards the others
Explanation
Projection removes unwanted columns while retaining the requested attributes.
- A
- 52
What is the schema of the result of projecting attribute list L from relation R?
- A
The attributes of the relation referenced by R
- B
Only the key attributes of R
- C
The attributes listed in L
- D
All attributes originally present in R
Correct answer
CThe attributes listed in L
Explanation
The output schema consists exactly of the attributes in the projection list L.
- A
- 53
Why can projection produce fewer tuples than the input relation?
- A
Different input tuples may become identical after unwanted attributes are removed
- B
Different input tuples are always retained as separate duplicates
- C
Projection automatically removes every tuple containing a null value
- D
Projection changes every tuple into a foreign-key reference
Correct answer
ADifferent input tuples may become identical after unwanted attributes are removed
Explanation
Because relations are sets, duplicate projected tuples are retained only once when different input tuples agree on the projected attributes.
- A
- 54
What happens when the projection list contains a key of the input relation?
- A
The output becomes a relation containing duplicate tuples
- B
The output necessarily has fewer tuples than the input
- C
The output has the same number of tuples as the input
- D
The output contains only the key value of the input relation
Correct answer
CThe output has the same number of tuples as the input
Explanation
A key uniquely identifies each input tuple, so projecting it preserves a distinct tuple for every input tuple.
- A
- 55
What result is produced by first selecting Student tuples with degree equal to M.S. and then projecting name?
- A
One tuple for every original student attribute
- B
One tuple for every department offering an M.S. degree
- C
One tuple for every M.S. enrollment record
- D
One tuple for each distinct M.S. student name
Correct answer
DOne tuple for each distinct M.S. student name
Explanation
Selection keeps M.S. students, and projection keeps only their names; repeated names appear once because the result is a set.
- A
- 56
Why can projecting only name from M.S. students lose information in the example?
- A
Students in different departments may have the same name
- B
Projection always removes all students with an M.S. degree
- C
Names cannot be stored in a relational database
- D
The name attribute is necessarily a foreign key to Course
Correct answer
AStudents in different departments may have the same name
Explanation
Two students named Mahesh can become one tuple when only name is projected, even though they represent different students.
- A
- 57
Why does projecting roll number and name from Student preserve the number of tuples?
- A
Name is always unique among all students
- B
Roll number is a key and prevents projected duplicates
- C
Degree and department number are automatically restored
- D
Projection preserves every discarded attribute internally
Correct answer
BRoll number is a key and prevents projected duplicates
Explanation
Because roll number is a key, no two Student tuples can produce the same roll-number-and-name combination.
- A
- 58
Which notation represents projection in relational algebra?
- A
δL(R)
- B
πL(R)
- C
σL(R)
- D
ρL(R)
Correct answer
BπL(R)
Explanation
The symbol π denotes projection, with L as the requested attribute list and R as the input relation.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.