Homework 5 - DDM
Homework 5 - DDM
-An entry in a table, consisting of values for each appropriate column. ->Tuple
-The set of mandatory columns within a table that is used to enforce uniqueness of rows, and
that is normally the most frequent means by which rows are accessed.-> Primary key
-A column or set of columns that refers to a primary key in the same table or another table. ->
Foreign key
-Collections of objects or relations, set of operators to act on those relations, and data integrity
for accuracy and consistency -> Relational Model
-Used to modify the table data by entering, changing, or removing rows -> Data Manipulation
Language (DML)
-Creates,changes and removes data structures from the database -> Data Definition Language
(DDL)
-Used to manage the changes made by DML statements -> Transition Control
-Used to give or remove access rights to the database and the structures within it -> Data
control Language (DCL)
The exact number of tables isnt provided, so you would need to reference the database schema
or documentation for this information.
Typically, the F_SHIFTS table is related to the F_STAFFS table through a foreign key. The F_SHIFTS
table would have a column like staff_id that references the primary key (staff_id) in the
F_STAFFS table.
How many rows of data have been entered in the F_PROMOTIONAL_MENUS table?
The number of rows in the F_PROMOTIONAL_MENUS table can be determined by querying the
table with a SELECT COUNT(*) SQL statement. Example:
In the F_FOOD_ITEMS table, column is a foreign-key column. What table and column is this
key referencing?
In many restaurant databases, a foreign key in the F_FOOD_ITEMS table could be menu_id,
which references the menu_id column in the F_MENUS table (or a similar related table).
List the primary key to foreign key relationships required to go from the F_SHIFTS table to the
F_REGULAR_MENUS table.
To establish a relationship between the F_SHIFTS and F_REGULAR_MENUS tables, the primary
key in F_REGULAR_MENUS (e.g., menu_id) would be referenced by a foreign key in the
F_SHIFTS table (e.g., menu_id).
To find which tables contain null values, you would need to query each table individually with a
query like:
SELECT * FROM table_name WHERE column_name IS NULL;
1. SELECT first_name, last_name FROM employees;
2. SELECT last_name AS Client, email AS Email Address FROM d_client;
3. SELECT last_name, salary * 1.05 + 0.50 AS new_salary FROM f_staffs;
4. c. SELECT *
5. a. Payment = (car_cost * 1.25) + 5.00 - (tax) - (license)
6. SELECT employee_id, last_name
FROM employees;
7. A. SELECTION (Youre asking for a specific value based on a condition).
B. PROJECTION (Youre selecting specific columns).
8. c. null * .05 = null (Any operation with null will result in null).
d. (null + 1.00) + 5.00 = 5.00 (Adding null results in null, so this would not return a valid number,
but it’s written in a way that could be confusing).
9. c. BEARS, COLOR, age.
10. b. SELECT and FROM
1. SELECT last_name, mailing_address FROM customers;
2. A. SELECT first_name FROM f_staffs;
b. SELECT first_name || ' ' || last_name AS "DJs on Demand Clients"
FROM d_clients;
c. SELECT DISTINCT f_order_lines FROM quantity;
d. SELECT order_number FROM f_orders;
3. SELECT ‘***’ || first_name || ’ ***’ AS Super Star FROM f_staffs
WHERE first_name IN (‘Sue;,’Bob’,’ Monique’);
4. Answer: d. No rows will be returned.
5. SELECT last_name, salary, salary * 1.05 AS ‘’Salary with 5% Raise’’ FROM f_staffs;
6. DESCRIBE employees;
7. SELECT inventory_item AS “Inventory Item”, cd_title AS “CD Title”, music_producer AS
“Music Producer”, year_purchased AS” Year Purchased” FROM d_cds;
8. Answer: True. The statement is correct.
9. Answer: True. The statement is correct.
10. SELECT employee_id, last_name, salary * 12 AS ANNUAL_SALARY FROM
employees;
11. Answer: Multiplication (salary * 12) will be evaluated first, as multiplication has higher precedence
than subtraction.
12. Answer: b. *
13. Answer: b. Projection
14. Answer: c. Employee
15. Answer: b. SELECT salary * (6 + 100)
16. Answer: c.
17. Answer: c. Keywords cannot be abbreviated or split across lines.
18. Answer: b.
19. Answer: a. SELCT * FROM employees; (There is a typo in SELCT instead
of SELECT).
1. SELECT first_name, last_name, address FROM customers WHERE customer_id = 456;
2. SELECT name, start_date, end_date FROM promotional_items
WHERE name = ‘ballpen and highlighter’;
3. SELECT ‘The 1997 recording in our database is ‘ || title
FROM d_cds WHERE year = 1997;
4. SELECT producer, title FROM d_cds
WHERE title = ‘Carpe Diem’; -- Corrected the case for ‘Carpe Diem’ (case-sensitive)
5. SELECT title, year FROM d_cds
WHERE year <2000;
6. SELECT salary
FROM employees
WHERE salary <= 5000;
7. SELECT studentno, fname, lname
FROM students
WHERE sex = ‘F’;
8. SELECT studentno AS "Student
Number" FROM students
WHERE major = ‘PE’;
9. SELECT *
FROM students
WHERE sex = ‘M’;
10. SELECT title, year
FROM d_cds
WHERE year != 2000;
11. SELECT first_name, last_name, birth_date FROM f_staffs
WHERE birth_date < TO_DATE(‘1980-01-01’,’YYYY-MM-DD’);
1. SELECT first_name, last_name, salary
FROM f_staffs
WHERE salary BETWEEN 5.00 AND 10.00;
2. SELECT location_type, comments
FROM d_venues
WHERE location_type =’Private Home’;
3. SELECT first_name, last_name
FROM f_staffs
WHERE salary >= 20.00 AND salary <= 60.00;
4. SELECT title
FROM d_cds
WHERE title LIKE ‘_a%’;
5. SELECT partner_name
FROM d_partners
WHERE authorized_expense IS NULL;
6. SELECT last_name AS ‘Possible Candidates’;
FROM employees
WHERE last_name LIKE ‘%s’;
7. Correct statement: WHERE quantity IS NULL
8. SELECT title
FROM d_songs
WHERE type_code IN (77, 12, 1);