StudyFox
कीमतेंब्लॉगएक्सटेंशनमुफ़्त टूल
  • कीमतें
  • ब्लॉग
  • एक्सटेंशन
  • मुफ़्त टूल
  • शुरू करेंसाइन इन
StudyFox

अपने नोट्स, PDF और स्लाइड्स को फ़्लैशकार्ड, क्विज़, नोट्स और माइंड मैप में बदलें।

StudyFox खोलें

स्टडी टूल्स

  • होमवर्क हेल्पर
  • नोट मेकर
  • फ़्लैशकार्ड मेकर
  • क्विज़ मेकर
  • माइंड मैप मेकर

प्रोडक्ट

  • कीमतें
  • Chrome एक्सटेंशन
  • मुफ़्त एक्सटेंशन
  • स्टडी सेट देखें
  • ब्लॉग

सहायता

  • सहायता केंद्र
  • संपर्क करें
  • गोपनीयता नीति
  • सेवा की शर्तें

तुलना करें

  • Chegg का विकल्प
  • Course Hero का विकल्प
  • Coursology का विकल्प
  • Photomath का विकल्प
  • Gauthmath का विकल्प
  • PhotoSolve का विकल्प
  • CollegeTools का विकल्प
  • Transcript का विकल्प
  • SmartSolve का विकल्प
  • Homeworkify का विकल्प
  • AnswersAi का विकल्प
  • StudyX का विकल्प
  • Quizlet का विकल्प
  • Anki का विकल्प
  • Knowt का विकल्प
  • Brainscape का विकल्प
  • सभी तुलनाएँ

© 2026 StudyFox AI. सर्वाधिकार सुरक्षित।

  • X
  • Discord
  • Instagram
ExploreEngineering & TechComputer ScienceDatabases Quiz: Relational Model and SQL

Quiz · Medium

Databases Quiz: Relational Model and SQL

Mixed questions on keys, NULL logic, joins, grouping, evaluation order and SQL safety.

by Kill h.20 questionsCreated Nov 20, 2026, 08:26 PM
Computer Science· DatabasesTags#sql#joins#relational-model#computer-science#databases

20 questions

  1. 1

    Which statement about a relation in the relational model is correct?

    • A

      Its rows have a fixed physical order

    • B

      Its columns have a fixed order and may repeat

    • It is a set of tuples sharing the same attributes

    • D

      It must contain at least one NULL

    A relation is a set of tuples over the same attributes; neither tuple order nor duplicate tuples carry meaning.

  2. 2

    Which expression returns rows where salary is unknown?

    • A

      WHERE salary = NULL

    • WHERE salary IS NULL

    • C

      WHERE salary == 0

    • D

      WHERE NOT salary

    Comparisons with NULL yield UNKNOWN, so equality never matches. IS NULL is the correct test.

  3. 3

    A table has 100 rows. 10 have bonus NULL. What does SELECT COUNT(bonus) FROM t return?

    • A

      100

    • 90

    • C

      10

    • D

      NULL

    COUNT(column) ignores NULLs, so only the 90 non-NULL values are counted. COUNT(*) would return 100.

  4. 4

    Which query returns only departments with more than 5 employees?

    • A

      SELECT dept FROM e WHERE COUNT(*) > 5 GROUP BY dept

    • SELECT dept FROM e GROUP BY dept HAVING COUNT(*) > 5

    • C

      SELECT dept FROM e GROUP BY dept WHERE COUNT(*) > 5

    • D

      SELECT dept FROM e HAVING dept > 5

    Aggregates can be filtered only after grouping, which is what HAVING is for. WHERE cannot contain aggregate functions.

  5. 5

    The shaded region in the diagram corresponds to which join of A with B?

    • INNER JOIN

    • B

      LEFT JOIN

    • C

      RIGHT JOIN

    • D

      CROSS JOIN

    Only the overlap, the rows that match in both tables, is returned by an inner join.

  6. 6

    The shaded region in the diagram (all of A and the overlap) is produced by which join?

    • A

      INNER JOIN

    • LEFT OUTER JOIN of A with B

    • C

      FULL OUTER JOIN

    • D

      A EXCEPT B

    A left outer join keeps every row from the left table and fills B's columns with NULL where there is no match.

  7. 7

    Which clause is evaluated first in the logical processing of a SELECT statement?

    • A

      WHERE

    • B

      SELECT

    • FROM

    • D

      ORDER BY

    FROM (and joins) comes first, then WHERE, GROUP BY, HAVING, SELECT, ORDER BY, LIMIT.

  8. 8

    Why does SELECT price * qty AS total FROM t WHERE total > 100 fail in standard SQL?

    • A

      Aliases cannot contain spaces

    • WHERE is evaluated before SELECT, so the alias does not exist yet

    • C

      total is a reserved word

    • D

      Multiplication is not allowed in SELECT

    WHERE runs before the SELECT list is computed, so the alias is not visible. Repeat the expression or use a subquery or CTE.

  9. 9

    What does SELECT * FROM a WHERE id NOT IN (SELECT a_id FROM b) return if b.a_id contains a NULL?

    • A

      All rows of a that are not in b

    • No rows

    • C

      Only rows where id is NULL

    • D

      An error

    NOT IN with a NULL in the list never evaluates to TRUE (it is UNKNOWN), so no rows qualify. NOT EXISTS avoids the problem.

  10. 10

    Scores are 95, 95, 90. Which function assigns ranks 1, 1, 2?

    • A

      ROW_NUMBER

    • B

      RANK

    • DENSE_RANK

    • D

      NTILE

    DENSE_RANK leaves no gaps after ties. RANK would give 1, 1, 3 and ROW_NUMBER 1, 2, 3.

  11. 11

    Which is the safest defence against SQL injection?

    • A

      Escape quotes by hand

    • B

      Hide the table names

    • Use parameterized queries (prepared statements)

    • D

      Run the database on a non-default port

    Parameters keep user input as data, never as SQL text, so it cannot change the query structure.

  12. 12

    What is the main difference between UNION and UNION ALL?

    • A

      UNION ALL removes duplicates

    • UNION removes duplicate rows, UNION ALL keeps them

    • C

      UNION works on one table only

    • D

      They are identical

    UNION needs extra work to remove duplicates, so UNION ALL is faster when duplicates are acceptable or impossible.

  13. 13

    Which statement removes all rows from a table but keeps the table definition?

    • A

      DROP TABLE t

    • TRUNCATE TABLE t

    • C

      ALTER TABLE t

    • D

      REMOVE t

    TRUNCATE empties the table quickly; DROP deletes the table itself.

  14. 14

    A foreign key column should normally:

    • A

      Be unique in the child table

    • Match an existing key in the parent table or be NULL

    • C

      Always be the primary key of the child

    • D

      Be indexed only in the parent table

    That is referential integrity. Uniqueness in the child is only needed for one-to-one relationships.

  15. 15

    How is a many-to-many relationship between students and courses implemented?

    • A

      A foreign key in students pointing to courses

    • B

      A comma-separated list of course ids in each student row

    • A junction table with foreign keys to both

    • D

      Two separate databases

    A junction table (for example enrollment) breaks M:N into two one-to-many relationships and keeps the data atomic.

  16. 16

    Why should money columns use DECIMAL rather than FLOAT?

    • A

      DECIMAL uses less storage

    • B

      FLOAT cannot store numbers above 1000

    • FLOAT is binary and cannot represent many decimal fractions exactly

    • D

      DECIMAL is faster for division

    For example 0.1 has no exact binary representation, so rounding errors accumulate in FLOAT arithmetic.

  17. 17

    Which statement correctly describes CHAR(10) and VARCHAR(10)?

    • CHAR pads values to 10 characters; VARCHAR stores only what is used

    • B

      They are the same in all systems

    • C

      VARCHAR is always padded

    • D

      CHAR cannot be indexed

    CHAR is fixed length with padding; VARCHAR is variable length up to the limit.

  18. 18

    Which query finds customers who have never placed an order?

    • A

      SELECT c.* FROM customers c INNER JOIN orders o ON o.cid = c.id

    • SELECT c.* FROM customers c LEFT JOIN orders o ON o.cid = c.id WHERE o.cid IS NULL

    • C

      SELECT c.* FROM customers c CROSS JOIN orders o

    • D

      SELECT c.* FROM customers c GROUP BY c.id HAVING o.cid IS NULL

    A left join keeps customers without matches, and the IS NULL test on the right-hand key isolates them (an anti-join).

  19. 19

    What happens with ON DELETE CASCADE when a parent row is deleted?

    • A

      The delete is refused

    • Child rows referencing it are deleted too

    • C

      Child foreign keys are set to 0

    • D

      Nothing changes

    CASCADE propagates the delete to dependent rows. RESTRICT would refuse it and SET NULL would clear the child keys.

  20. 20

    In a relational table, an attribute is:

    • A

      A row

    • A column

    • C

      The whole table

    • D

      A constraint

    Attribute = column, tuple = row, relation = table.