# 2.2 Assignment

course: Academy — 65-GENAI-for-Engineers
module: Academy/65-GENAI-for-Engineers
type: pdf
source_url: https://personal-learn.armco.dev/files/Academy/65-GENAI-for-Engineers/assignments/2.2_Assignment__Concepts_of_Primary_Keys,_Foreign_Keys,_and_Schemas/2.2_Assignment.pdf
pages: 1

---
[page 1]
2.2 Assignment Questions 
 Short Answer / Conceptual Questions 
 1.  Define the terms: Primary Key, Foreign Key, and Schema. Provide one example for 
 each. 
 2.  Explain how primary and foreign keys help enforce data integrity. 
 3.  What are the consequences of not defining proper keys in a relational database? 
 Hands-On / Practical Tasks 
 4.  Create a database schema for an online bookstore that includes the following tables: 
 ○  Books (BookID, Title, AuthorID) 
 ○  Authors (AuthorID, Name, Country) 
 ○  Orders (OrderID, BookID, CustomerID, Quantity) 
 ○  Customers (CustomerID, Name, Email) 
 ○  Define all primary and foreign keys. 
 5.  Implement the schema using SQL in any RDBMS (MySQL, PostgreSQL, or SQLite). 
 ○  Insert sample data into all tables. 
 ○  Use  CREATE TABLE  ,  INSERT INTO  , and  FOREIGN KEY  clauses  appropriately. 
 6.  Write SQL queries to: 
 a. List all orders along with book titles and customer names. 
 b. Show all authors and the books they’ve written. 
 c. Find customers who have ordered more than 3 books in total.