1. What is a relational database management system (RDBMS)? ANS: A RDBMS is a system that allows for the management of a relational DB. A relational DB is a one that contains tables where data is stored. Users create rules between these tables and define their relationships. 2. What is SQL? ANS: SQL is Structured Query Language and it is a language that is used to communicate with a DB. 3. What is an ER model? ANS: The ER or Entitiy Relation model describes the elements of data as well as their relationship to other data elements found in the same domain. It is the preliminary design for a DB. 4. Define the following terms: One-to-one relationship, one-to-many relationship, and many-to-many relationship. ANS: One-to-One: Most basic relationship. Here one element corresponds to another single element. For example, one person has one SSN. One-to-Many: More complex than before. Here one element may correspond to several other elements. For example, One book has many pages. Many-to-Many: Most complex relationship. Many elements can correspond to many other elements. For example, many books can have be written by an author, an author can also write many books. 5. What is the purpose of a primary key? Why should it be unique? ANS: A primary key is a unique identifier found within a table. Most of the time it is an Id. It must be unique because in order for data to maintain integrity. This Id will help when creating a relationship and connection between two tables in a JOIN operation. 6. Create a table called Customers that has eight properties with these exact names. ANS: CREATE TABLE IF NOT EXISTS customers ( id INT NOT NULL AUTO_INCREMENT, firstname VARCHAR(255) NOT NULL, lastname VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL, state CHAR(2) NOT NULL, zip INT NOT NULL CHECK(zip between 00000 and 99999), email VARCHAR(255) NOT NULL, PRIMARY KEY (id) ); 7. Alter the Customers table by adding a new column for a property called age, which is an unsigned integer that cannot be null. ANS: ALTER TABLE customers ADD age INT(3) NOT NULL; 8. Add at least 3 records to the Customers table. ANS: INSERT INTO customers (id, firstname, lastname, address, city, state, zip, email) VALUES ('Cesar', 'Aleman', '1776 Freedom St', 'Boston', 'MA', 18127, 'givemefreedom@donttreadonme.usa'), ('Ben', 'Franklin', '0704 Independence BLVD', 'Boston', 'MA', 18127, 'realbenfrank@webeatthebrits.com'), ('Tom', 'Jefferson', '1 Great Ln', 'Shadwell', 'VA', 49547, 'isignedtheconstitution@foundingfather.com'); 9. Select all of your customers. ANS: Select * from customers; 10. Create a table called Products that has four properties with these exact names. ANS: CREATE TABLE IF NOT EXISTS products ( id INT NOT NULL AUTO_INCREMENT, title VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, price INT NOT NULL, PRIMARY KEY (id) ); 11. Add at least 3 records to the products ANS: INSERT INTO products(id, title, description, price) VALUES ('Thumbtack', 'It is a Thumbtack that sticks to things', 100.00), ('Hotwheel', 'A miniature version of cars that I cannot afford', 1.00), ('Ten Quid', 'A tenner or ten Pound note from her Majesty', 11.00); 12. Select all of your products. ANS: Select * from products; 13. Update one of your products' price to $49.99. ANS: UPDATE products SET price = 49.99 WHERE id = 0; 14. Select all of your products that are less than $100. ANS: SELECT * FROM products WHERE price > 100; 15. Delete your last product record. ANS: DELETE FROM products WHERE id = 2; 16. Create a table called Orders that has four properties with these exact names. ANS: CREATE TABLE IF NOT EXISTS orders ( id INT NOT NULL AUTO_INCREMENT, cid VARCHAR(255) NOT NULL, amount DECIMAL NOT NULL, date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id) ); 17. Using the data that was added to the Customers and Products tables, add at least 3 records to the Orders table. ANS: INSERT INTO orders(id, cid, amount, date) VALUES (0, 10.00), (1, 100.00), (2, 150.00); 18. Select all orders where the customer ID is that of your first customer. ANS: SELECT * FROM orders WHERE cid = 0; 19. Select all orders above $100. ANS: SELECT * FROM orders WHERE amount > 100; 20. Drop your Orders table. ANS: DROP TABLE orders;