Practice DDL, default-aware INSERTs, analytical SELECT queries, and maintenance operations against the Library schema. Solve each task using the side-by-side ER models and conceptual hints.
CREATE TABLE Books (...) statement conforming strictly to the ER diagram:
id: INT Primary Key.title: VARCHAR(150), prohibited from being NULL.isbn: VARCHAR(20), Unique and prohibited from being NULL.publicationYear: INT with a check constraint enforcing values strictly greater than 1800.totalCopies: INT with a default fallback of 1.id INT PRIMARY KEY.NOT NULL.UNIQUE.CHECK (column_name > value).DEFAULT value.VARCHAR(150) (the diagram's varchar_150 is only notation).INSERT INTO Books statement to insert a record:
id = 101, title = 'Database Fundamentals', and isbn = '978-0133970777'.totalCopies (so it inherits its default 1) or publicationYear (leaving it unpopulated as NULL).INSERT INTO Books (col1, col2, col3) VALUES (...).DEFAULT; with no default it becomes NULL, but only if the column allows NULL (omitting a NOT NULL column without a default makes the insert fail).SELECT query on the Books table:
title and isbn columns.title starts with the prefix 'Data' (e.g. 'Database Fundamentals', 'Data Structures').WHERE clause, use the LIKE operator instead of =.% symbol represents zero, one, or multiple arbitrary characters. Placing % after a word matches anything starting with that prefix, while '%Data%' would match it anywhere in the text.*. Note that LIKE case sensitivity depends on the database (case-insensitive in SQLite and MySQL, case-sensitive in PostgreSQL).Members table:
fullName and a computed column calculating active tenure as 2026 - joinYear.membershipYears to this computed column.membershipType = 'S').SELECT projection list: SELECT col, (2026 - col2) AS alias_name FROM .... Use AS to name the computed column.WHERE membershipType = 'S'.Members table to inspect edge entries:
*).joinYear is unassigned (NULL) OR where the membershipType is equal to 'G' (Guest).= NULL always evaluates to UNKNOWN. Always write column_name IS NULL.OR keyword.Books table to extract publication cohorts:
*).BETWEEN) OR having a publicationYear in the historic release set (1850, 1875) (using IN).publicationYear in descending order (DESC).BETWEEN low AND high for continuous inclusive intervals.IN (val1, val2) for explicit discrete sets.OR, since a book needs to satisfy only one of them.ORDER BY column_name DESC as the final clause of your query.Loans table to compute baseline metrics across all loans:
COUNT(*).overdueDays (excluding NULLs) using COUNT(overdueDays).AVG(durationDays).COUNT(*) counts every row in the table (or in each group), including rows containing NULLs.COUNT(columnName) counts non-null occurrences in that specific column.AVG(columnName) calculates the mathematical mean of all non-null numbers in that column.Members table:
membershipType.memberCount.membershipType.SELECT clause must appear in the GROUP BY clause.SELECT category_col, COUNT(*) AS alias FROM table GROUP BY category_col;.NULL category are not dropped: all NULLs form one group of their own.Loans table to find repeat overdue borrowers:
memberId, the total overdue loan count aliased as loanCount, and the average overdue days aliased as avgOverdue.overdueDays > 0).memberId.HAVING to only display members who have strictly more than 2 such overdue loans.WHERE evaluates raw rows before grouping occurs (use it for overdueDays > 0).HAVING evaluates grouped results after aggregation (use it for COUNT(*) > 2).WHERE (WHERE COUNT(*) > 2 is an error).loanCount and avgOverdue for the two aggregate columns.Members separated by semicolons:
membershipType = 'F' for all members who joined before 2010 (joinYear < 2010).joinYear IS NULL AND whose membershipType is 'S'.UPDATE TableName SET column = 'newValue' WHERE condition;.DELETE FROM TableName WHERE col IS NULL AND col2 = 'val';.IS NULL, not equality.joinYear are never matched by joinYear < 2010 (the comparison is UNKNOWN), so the UPDATE leaves them alone.
This certifies that
[Student Name]
Student Identification Number: [Student ID]
has successfully implemented, analyzed, and manipulated single-table database structures conforming to ER model standards, demonstrating mastery across table definition (DDL), record insertion with default resolution, compound analytical queries, grouped aggregations, and row-level maintenance operations.