Conceptual Questions: 1. What is relational database management system (RDBMS)? - RDBMS is a piece of software that allows you to modify, access, and process data stored in a relational database. Relational databases are databases where data is stored into separate tables. These tables have user-defined rules that define the relatioship between data fields. mySQL is a relationsal database management system. 2. What is SQL? - SQL stands for Structured Query Language. It is the language used to communicate with a database. It's the most common standardizes language used to access databases. 3. What is an ER model? - ER model stands for Entity-Relationship Model. The ER model is a popular conceptual data model. It's used for the design of database applications. Many database design tools use this concept. 4. Define the following terms: - A one-to-one relationship is when a row in one table matches only one row in another table. - A one-to-many relationship is when a row in one table matches multiple rows in another table. - A many-to-many relationship is when a row from in one table matches multiple rows in another table, and a row in the other table can have multiple matching rows in the first table. 5. What is the purpose of a primary key? Why should it be unique? - A primary key is a single column in a table that identifies all the rows in the table. You can only have one primary key in each table. It should be unique because you need the primary key uniquely identify the row in your table. ------------------------------------------------------------------------- SQL Exercises: 1. CREATE TABLE Customers( -> id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> firstName VARCHAR(20) NOT NULL, -> lastName VARCHAR(20) NOT NULL, -> address VARCHAR(20) NOT NULL, -> city VARCHAR(20) NOT NULL, -> state VARCHAR(2) NOT NULL, -> zip MEDIUMINT UNSIGNED NOT NULL, -> email VARCHAR(20) NOT NULL); 2. ALTER TABLE Customers -> ADD age MEDIUMINT UNSIGNED NOT NULL; 3. INSERT INTO Customers -> VALUES -> (1, "John", "Doe", "1111 Easy St", "Bakersfield", "CA", 93301, "john@gmail.com", 20), -> (2, "Jane", "Doe", "2222 Easy St", "Bakersfield", "CA", 93301, "jane@gmail.com", 20), -> (3, "Matt", "Doe", "3333 Easy St", "Bakersfield", "CA", 93301, "matt@gmail.com", 20); 4. SELECT * FROM Customers; 5. CREATE TABLE Products( -> id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> title VARCHAR(20) NOT NULL, -> description VARCHAR(20) NOT NULL, -> price DECIMAL(5, 2) NOT NULL); 6. INSERT INTO Products( -> VALUES -> (1, "paper towels", "used to clean things", 2.99), -> (2, "sweatpants", "keep legs warm", 6.99), -> (3, "shirt", "keep body warm", 4.99), 7. SELECT * FROM Products; 8. UPDATE Products( -> SET Price = 49.99 -> WHERE id = 1; 9. SELECT price FROM Products; 10. DELETE FROM Products WHERE id = 3; 11. CREATE TABLE Orders( -> VALUES -> id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> cid INT NOT NULL REFERENCES Customers (id), -> amount DECIMAL UNSIGNED NOT NULL, -> date TIMESTAMP DEFAULT CURRENT_TIMESTAMP); 12. INSERT INTO Orders SELECT * FROM Customers; 13. SELECT id FROM Orders; 14. SELECT price FROM Orders; 15. DROP TABLE Orders;