Database Exam 2

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/68

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 12:51 AM on 4/26/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

69 Terms

1
New cards

What are entity integrity constraints in SQL?

Constraints that ensure each entity in a database is unique and identifiable.

2
New cards

What are referential integrity constraints in SQL?

Constraints that ensure relationships between tables remain consistent.

3
New cards

What is the purpose of the NOT NULL constraint?

To ensure that a column cannot have a NULL value.

4
New cards

What does the DEFAULT constraint do?

Specifies a default value for a column when no value is provided.

5
New cards

What is the CHECK constraint?

Ensures that all values in a column satisfy a specific condition.

6
New cards

What is a FOREIGN KEY in SQL?

A key used to link two tables together, referencing the primary key of another table.

7
New cards

What does the RESTRICT action do in referential integrity?

Prevents the deletion of a referenced row in a parent table.

8
New cards

What is the purpose of the CASCADE action?

Automatically deletes or updates rows in child tables when the corresponding row in the parent table is deleted or updated.

9
New cards

What does SET NULL do in referential integrity?

Sets the foreign key value to NULL when the referenced row is deleted.

10
New cards

What is SET DEFAULT in referential integrity?

Sets the foreign key value to a default value when the referenced row is deleted.

11
New cards

What is a nested query in SQL?

A query within another query, used for fetching values for comparisons.

12
New cards

What is a JOIN operation in SQL?

Combines rows from two or more tables based on a related column.

13
New cards

What is a NATURAL JOIN?

A join that automatically matches columns with the same name in both tables.

14
New cards

What is an OUTER JOIN?

A join that includes all rows from one table and matched rows from another, padding unmatched rows with NULLs.

15
New cards

What is a LEFT OUTER JOIN?

Keeps all tuples from the left table and matches with the right table.

16
New cards

What is a RIGHT OUTER JOIN?

Keeps all tuples from the right table and matches with the left table.

17
New cards

What is a FULL OUTER JOIN?

Keeps all tuples from both tables, matching where possible.

18
New cards

What is a CROSS JOIN?

Creates a Cartesian product of two tables, combining all possible tuples.

19
New cards

What are aggregate functions in SQL?

Functions that summarize data from multiple rows into a single value.

20
New cards

What does the COUNT function do?

Counts the number of rows in a specified dataset.

21
New cards

What does the SUM function do?

Adds up all the values in a specified numeric column.

22
New cards

What does the MAX function do?

Returns the maximum value in a specified column.

23
New cards

What does the MIN function do?

Returns the minimum value in a specified column.

24
New cards

What does the AVG function do?

Calculates the average of numeric values in a specified column.

25
New cards

What is the GROUP BY clause used for?

To group rows that have the same values in specified columns into summary rows.

26
New cards

What is the HAVING clause used for?

To filter records that work on summarized GROUP BY results.

27
New cards

What is the purpose of the WITH clause in SQL?

It defines a temporary table used in a single query and is dropped afterward.

28
New cards

What does the SELECT statement retrieve for departments with an average salary over $30,000?

It retrieves the department name and the number of employees working for that department.

29
New cards

How can we count male employees making over $30,000 in SQL?

By using a SELECT statement with COUNT(*) and filtering by Sex = 'M' and AVG(Salary) > 30000.

30
New cards

What query retrieves names and majors of straight-A students?

It uses a JOIN between STUDENT and GRADE_REPORT and filters with HAVING SUM(CASE WHEN Grade = 'A' THEN 1 ELSE 0 END) = 0.

31
New cards

What query retrieves names and majors of students without any A grades?

It uses a JOIN and filters with HAVING SUM(CASE WHEN GRADE IS NOT 'A' THEN 0 ELSE 1 END) = 0.

32
New cards

How do you retrieve names of employees in the department with the highest paid employee?

By using a nested query that selects Dno from Employee where Salary is the maximum.

33
New cards

What is the SQL query to find employees whose supervisor's supervisor has a specific SSN?

It uses a nested IN query to filter employees based on their supervisor's supervisor's SSN.

34
New cards

What does the query to find employees making at least $10,000 more than the lowest paid employee do?

It compares each employee's salary to the minimum salary plus $10,000.

35
New cards

What information does the Department_Info view contain?

It includes department name, manager name, and manager salary for every department.

36
New cards

What does the Employee_Info view display?

It shows employee name, supervisor name, and employee salary for each employee in the Research department.

37
New cards

What does the ProjectInfo view provide?

It includes project name, controlling department name, number of employees, and total hours worked per week.

38
New cards

What are insertion anomalies in databases?

They occur when you cannot add data because some other data is missing.

<p>They occur when you cannot add data because some other data is missing.</p>
39
New cards

What are deletion anomalies in databases?

They happen when unrelated information is lost while deleting a specific record.

40
New cards

What are modification anomalies in databases?

They occur when data is changed in one place but not others, leading to inconsistency.

41
New cards

Why should NULLs in a relation be avoided?

They complicate joins, waste storage, and cause ambiguous results in aggregate functions.

42
New cards

What is a functional dependency?

It is a constraint between two sets of attributes where the left side must equal the right side for any two tuples.

43
New cards

Why can't we infer a functional dependency from a single relation state?

It is a property of the relation schema, not a specific state, and must be defined by a designer.

44
New cards

What is the definition of first normal form (1NF)?

A relation is in 1NF if all attributes consist of single atomic (indivisible) values.

45
New cards

What is the definition of second normal form (2NF)?

A relation is in 2NF if every nonprime attribute has a full functional dependency on the primary key.

46
New cards

What undesirable dependencies does 2NF avoid?

It avoids partial dependencies where a nonprime attribute depends on only part of a composite key.

47
New cards

What undesirable dependencies does 3NF avoid?

It avoids both partial and transitive dependencies, ensuring higher data integrity.

48
New cards

How do the generalized definitions of 2NF and 3NF extend beyond primary keys?

They consider all candidate keys, not just the primary key, for dependency checks.

49
New cards

What is the definition of 2NF?

Second Normal Form (2NF) extends the definition of normalization beyond primary keys by considering all candidate keys.

50
New cards

What is the definition of 3NF?

Third Normal Form (3NF) is a database normalization form that requires that all non-prime attributes are not only dependent on the primary key but also independent of each other.

51
New cards

What is Boyce-Codd Normal Form (BCNF)?

A relation is in Boyce-Codd Normal Form (BCNF) if, for every nontrivial functional dependency A → B, A is a superkey of the relation.

52
New cards

How does BCNF differ from 3NF?

BCNF differs from 3NF by omitting the option that allows B to be a prime attribute in a nontrivial functional dependency.

53
New cards

Why is BCNF considered a stronger form than 3NF?

BCNF is stronger than 3NF because there are relations that are in 3NF but not in BCNF.

54
New cards

What are insertion anomalies?

Insertion anomalies occur when adding a new record requires the re-entry of information, potentially leading to inconsistency.

55
New cards

What are deletion anomalies?

Deletion anomalies occur when deleting a record results in the loss of additional information that should be retained.

56
New cards

What are modification anomalies?

Modification anomalies occur when changing a value requires updates to multiple records, increasing the risk of inconsistency.

57
New cards

What is the functional dependency for a student's information?

{Ssn} → {Sname, Snum, Sc_addr, Sc_phone, Sp_addr, Sp_phone, Bdate, Sex, Class, Major_code, Minor_code, Prog}

58
New cards

What is the functional dependency for a department's information?

{Dname} → {Dcode, Doffice, Dphone, Dcollege}

59
New cards

What is the functional dependency for a course's information?

{Cnum} → {Cname, Cdesc, Credit, Level, Cdept}

60
New cards

What is the functional dependency for a section's information?

{Sec_course, Semester, Year, Sec_num} → {Iname}

61
New cards

What is the functional dependency for a grade record?

{Ssn, Sec_course, Semester, Year, Sec_num} → {Grade}

62
New cards

What is the relational schema for STUDENT?

STUDENT (Ssn, Snum, Sname, Sc_addr, Sc_phone, Sp_addr, Sp_phone, Bdate, Sex, Class, Major_code, Minor_code, Prog)

63
New cards

What is the relational schema for DEPARTMENT?

DEPARTMENT (Dcode, Dname, Doffice, Dphone, Dcollege)

64
New cards

What is the relational schema for COURSE?

COURSE (Cnum, Cname, Cdesc, Credit, Level, Cdept)

65
New cards

What is the relational schema for SECTION?

SECTION (Sec_course, Semester, Year, Sec_num, Iname)

66
New cards

What is the relational schema for GRADE_RECORD?

GRADE_RECORD (Ssn, Sec_course, Semester, Year, Sec_num, Grade)

67
New cards

What is the first normal form (1NF)?

A relation is in first normal form if it contains no multivalued attributes or nested relations.

68
New cards

What is the second normal form (2NF) based on primary key?

A relation is in second normal form based on primary key if every nonprime attribute is fully functionally dependent on the primary key.

69
New cards

What is the third normal form (3NF) based on primary key?

A relation is in third normal form based on primary key if there are no transitive dependencies among nonprime attributes.