1. What is a relational database management system (RDBMS)? Software that allows you to modify, access, and process data in a relational database. MySQL, postgres, and Oracle are examples of RDMBS. 2. What is SQL? SQL stands for Structured Query Language. It is the Language used to retrieve data from a SQL database. 3. What is an ER model? ER model stands for Entity Relationship model. It is a diagram representing entities in a database and using lines to connect them describing their relationship. 4. Define the following terms: One-to-one relationship, one-to-many relationship, and many-to-many relationship. One to one: Relation A has one row that is related to relation B. AKA the primary key of a row in table A will be found in one row in table B as the foreign key. One-To-Many: Relation A has one row related to many rows in relation B. AKA the primary key of relation A will be found in many rows as the foreign key in relation B. Many-to-many: Relation A will have many rows related to many rows in relation B. The primary Keys of A can be found as the foreign key in many rows of B, and the primary key of a row in B can be found as the foreign key of many rows in A. 5. What is the purpose of a primary key? Why should it be unique? The purpose of a primary key is to be able to uniquely identify a row in a table. It must be unique to be able to perform queries linking primary keys and foreign keys to process data in a database correctly. If it were not unique primary keys could not uniquely identify a row in a table. ==== DB Queries 1. CREATE TABLE Customers ( id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, 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(5) NOT NULL, email VARCHAR(255) NOT NULL ); 2. ALTER TABLE Customers ADD age INT UNSIGNED NOT NULL; 3. INSERT INTO Customers (firstName, lastName, address, city, state, zip, email, age) VALUES("Joey", "Shafer", "1234 address", "Bakersfield", "CA", 93312, "jshafer3@csub.edu", 24); INSERT INTO Customers (firstName, lastName, address, city, state, zip, email, age) VALUES("Brian", "David", "5643 location", "Provo", "UT", 93312, "Brian@csub.edu", 30); INSERT INTO Customers (firstName, lastName, address, city, state, zip, email, age) VALUES("Krissy", "Janae", "23423 place", "Fresno", "CA", 93312, "krissy@csub.edu", 21); 4. select * from Customers; 5. CREATE TABLE Products( id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, title VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, price decimal(5,2) NOT NULL ); 6. insert into Products(title, description, price) VALUES ("productA", "amazing", 123.23); insert into Products(title, description, price) VALUES ("productB", "Bmazing", 456.23); insert into Products(title, description, price) VALUES ("productC", "Cmazing", 79.23); 7. select * from Products; 8. update Products set price = 49.99 where Products.id = 1; 9. select * from Products where Products.price < 100; 10. delete from Products order by id DESC LIMIT 1; 11. CREATE TABLE Orders( id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, cid INT NOT NULL REFERENCES Products(id), price decimal(5,2) NOT NULL, date timestamp default CURRENT_TIMESTAMP ); 12. insert into Orders(cid, price) VALUES (1, 12.45); insert into Orders(cid, price, date) VALUES (2, 7.55, "2021-03-16 19:02:15"); insert into Orders(cid, price) VALUES (1, 45); 13. select * from Orders where Orders.cid = 1; 14. select * from Orders where price > 100; 15. DROP TABLE IF EXISTS Orders;