Database Systems Review: SQL, ERDs, Normalization, and Relational Algebra

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/49

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

50 Terms

1
New cards

What is the SQL clause that specifies the table(s) from which data is to be retrieved?

FROM

2
New cards

What clause in an SQL statement adds a condition to limit the rows to be displayed?

WHERE

3
New cards

What is the comparison operator used in an SQL statement to check whether an attribute does or does not have a value?

IS NULL or IS NOT NULL

4
New cards

What is a query that is embedded inside of another query?

subquery

5
New cards

What is the process for evaluating and correcting table structures to minimize data redundancies and anomalies?

normalization

6
New cards

What query clause will combine rows with the same values into summary rows?

GROUP BY clause

7
New cards

What is an attribute used as a primary key in one table and as a reference in another table?

foreign key (FK)

8
New cards

What is the type of relationship created when each team may have many players and each player may be on one team?

1:M (one-to-many)

9
New cards

What is an attribute whose value is calculated from other attributes?

derived attributes

10
New cards

What term refers to the cardinalities in an ERD?

cardinalities - One to many, one to one, many to many, etc..

11
New cards

What is the proper model/design for the business rules where a student may enroll in many classes and each class may enroll many students?

Many-to-Many relationship

<p>Many-to-Many relationship</p>
12
New cards

What is the SQL command used to create a table's structure with its attributes and constraints?

CREATE TABLE

13
New cards

What SQL command is used to remove a table structure from a database?

DROP TABLE

14
New cards

What is the SQL statement required to insert a row into the CUSTOMER table with specified attributes?

INSERT INTO CUSTOMER (Cust_LName, Cust_FName)
VALUES
('Bright','Brittany');

15
New cards

What SQL statement would create a table named CUSTOMER with specified attributes?

CREATE TABLE CUSTOMER(
Cust_ID INTEGER NOT NULL,
Cust_Fname VARCHAR(50),
Cust_Lname VARCHAR(50),
PRIMARY KEY(Cust_ID));
);

16
New cards

What is the SQL statement for removing a duplicated customer with an ID of 45?

DELETE FROM CUSTOMER
WHERE Cust_ID = 45;

17
New cards

What is the set of commands that allow a database administrator to DEFINE / CREATE the database structure?

Data Definition Language (DDL)

18
New cards

What are common data types for SQL? Name at least 3.

INTEGER, DOUBLE/DECIMAL, CHAR, VARCHAR, DATE

19
New cards

What is the SQL command used for the construction of table structures?

CREATE

20
New cards

What are 3 of the SQL constraints?

NOT NULL, UNIQUE, DEFAULT, CHECK, PRIMARY KEY, FOREIGN KEY

21
New cards

What is the SQL statement to remove a row from the EMPLOYEE table with Employee ID # 67564?

DELETE FROM EMPLOYEE
WHERE EmpID = 67564;

22
New cards

What SQL statement displays the student first and last name for any student whose last name starts with 'S'?

SELECT stuLName, stuFName
FROM STUDENT
WHERE stuLName LIKE 'S%';

23
New cards

What is the term for a set of commands that allow for the manipulation of data in a database?

Data Manipulation Language (DML)

24
New cards

What SQL command is used to retrieve data from tables that yields the values of all rows or a subset of rows based on a given condition?

SELECT

25
New cards

What are alternative names for a column or table in SQL, following the AS keyword?

aliases

26
New cards

What is the order of operations for calculated/derived fields in a database?

Parenthesis, Exponents, Multiplication & Division (left to right), Addition & Subtraction (left to right)

27
New cards

What SQL clause produces a list of unique values for an attribute?

DISTINCT

28
New cards

What are the different clauses that can be added to data fields to limit their contents?

constraints (e.g. NOT NULL, DEFAULT, UNIQUE)

29
New cards

What are the 3 wildcard characters in SQL and what do they do?

* (asterisks) Returns all columns, % (percent) Any & All characters, _ (underscore) One Single Character

30
New cards

What SQL command is used to retrieve data from multiple tables?

JOIN

31
New cards

What is the general syntax of a SELECT statement including a standard JOIN?

SELECT column1, column2
FROM table1 JOIN table2
ON table1.col = table2.col

32
New cards

What type of query returns the rows with and without matching values in another table?

outer join

33
New cards

What type of query would you use to determine which vendors we have not purchased any products from?

OUTER JOIN

34
New cards

What is the difference between a right and left outer join?

Left outer join returns all rows in the FROM table; Right outer join returns all rows in the JOIN table.

35
New cards

What SQL query would you use to display customer name, order number, order date, and order status for all orders?

SELECT C.CustName, O.OrderNum, O.OrderDate, O.OrderStatus
FROM CUSTOMER C
JOIN ORDER O
ON C.CustID = O.CustID

36
New cards

What SQL query would you use to find customers who have not purchased anything?

SELECT C.Cust_ID, C.Cust_Name
FROM CUSTOMER C
LEFT OUTER JOIN ORDER O
ON C.Cust_ID = O.Cust_ID
WHERE O.Order_ID IS NULL

37
New cards

What characters/symbols are found around any subquery within an SQL statement?

Open/close parenthesis

38
New cards

When should a subquery be used instead of a join?

A subquery should be used when data from only 1 table needs to be displayed or when performance dictates the use of a join.

39
New cards

What is the first query in an SQL statement that includes a subquery called?

outer query

40
New cards

What are the two primary sections of a query that a subquery can be implemented inside?

FROM & Condition (WHERE or HAVING)

41
New cards

What operator is required when a subquery returns more than 1 value in a WHERE condition?

IN operator

42
New cards

What is executed first in a subquery consisting of an outer query and an inner query?

the inner query

43
New cards

What query is used to display products where the product price is greater than the overall average product price?

SELECT Prod_Num, Prod_Price
FROM PRODUCT
WHERE Prod_Price >= (SELECT AVG(Prod_Price) FROM PRODUCT)

44
New cards

What is used to depict data models and queries utilizing mathematical concepts?

relational algebra

45
New cards

What symbol is used to depict the WHERE portion of an SQL's SELECT statement with relational algebra?

the SELECT/SIGMA symbol (σ)

46
New cards

What symbol is used to depict the selection of columns for a SELECT statement with relational algebra?

the PROJECT symbol (π)

47
New cards

What symbol is used to depict the joining (inner) of two tables in a SELECT statement with relational algebra?

the theta symbol (⋈)

48
New cards

What symbols are used to depict a left and right outer join in a SELECT statement with relational algebra?

the right and left theta symbols (⟕ for Left Outer Join, ⟖ for Right Outer Join)

49
New cards

What SQL query corresponds to the relational algebraic equation π(custID, fName, lName) σ(OrderID IS NULL) (CUSTOMER C ⟕ INVOICE I (C.CustID = I.CustID))?

SELECT custID, fName, lName
FROM CUSTOMER C
LEFT OUTER JOIN INVOICE I
ON C.CustID = I.CustID
WHERE I.OrderID IS NULL

50
New cards

What relational algebra corresponds to the query
SELECT fName, lName FROM EMPLOYEE
WHERE EmpID IN (SELECT Mngr_ID FROM EMPLOYEE WHERE fName = 'Brittany' AND lName = 'Bright')?

π(fName, lName) σ(fName = 'Brittany' ∧ lName = 'Bright') (EMPLOYEE E ⨝ EMPLOYEE EE (E.EmpID = EE.Mngr_ID))

//Will not be given something complex like this.