Programming Assignment Unit 4
Programming Assignment Unit 4
CS 2203-01 - Databases 1
Lutalo Martin
-- DATA INSERTION
-- EXAMPLE QUERIES
/*
KEY DESIGN DECISIONS:
1. Normalization:
- Achieved 3NF by separating entities into distinct tables
- No redundant data storage
- All non-key attributes depend only on primary keys
2. Referential Integrity:
- ON DELETE CASCADE ensures automatic cleanup of loan records
- Prevents orphaned records when books/members are deleted
3. Data Validation:
- CHECK constraints enforce business rules
- NOT NULL constraints prevent missing critical data
- UNIQUE constraint on email prevents duplicate accounts
4. Practical Considerations:
- ISBN as natural primary key for books
- Default values simplify common operations
- Quantity tracking enables inventory management
*/
Explanation
SQL is divided into several components—DDL, DML, and DCL—that serve distinct purposes.
DDL statements such as CREATE and ALTER define and manage schema structures, while
DML commands like INSERT, SELECT, UPDATE, and DELETE enable efficient data
manipulation (Vidhya et al., 2016). These commands are foundational for database operations
and essential for data retrieval and integrity.
Using appropriate SQL domain types (e.g., VARCHAR, INT, DATE) helps ensure data accuracy,
consistency, and optimal storage (Peterson, 2023). By defining relationships with FOREIGN
KEY constraints, the schema enforces referential integrity between tables—an essential aspect of
relational databases (GeeksforGeeks, 2025).
The SQL queries implemented in this assignment provide the ability to add and track members,
catalog books, and monitor loans. For instance, updating the quantity of books upon lending
ensures the system reflects real-time inventory. Deleting members when necessary maintains a
clean and updated database.
Screenshots of output
Conclusion
This assignment showcases how SQL can be used to model and manage a library system. By
defining a structured schema and leveraging SQL commands, we ensure reliable data storage and
operations. Understanding core SQL operations like CREATE, INSERT, SELECT, UPDATE,
and DELETE equips database managers to efficiently handle day-to-day tasks (EnableGeek, n.d.;
Codecademy, 2025).
References
Vidhya, V., Jeyaram, G., & Ishwarya, K. (2016). Database management systems. Alpha
Science International.
Peterson, R. (2023, December 16). SQL Cheat sheet with commands & description (2024).
GURU99. https://www.guru99.com/sql-cheat-sheet.html
SQL: How to create and delete a table with SQL query. (n.d.). EnableGeek.
https://www.enablegeek.com/tutorial/create-delete-table-sql-query/
https://www.geeksforgeeks.org/database-schemas/
Codecademy. (2025, February 26). SQL Commands list: Basic database queries.
https://www.codecademy.com/article/sql-commands