Ensures the foreign key values only reference values in the primary key, ensuring referential integrity.
Back
COUNT and AVG and SUM
Front
COUNT counts the number of rows selected. Key to remember it doesn't return number of columns.
SELECT COUNT(column_name)
FROM table_name;
AVG returns the numeric average of column(s).
SELECT AVG(column_name)
FROM table_name;
SUM returns total sum of column(s).
SELECT SUM(column_name)
FROM table_name;
Back
DELETE
Front
DELETE FROM table
WHERE condition;
Back
LIKE
Front
SELECT column_name
FROM table_name
LIKE %string%;
SELECT column_name
FROM table_name
LIKE 'str_ng';
Back
GROUP BY
Front
Groups the selected rows based on one or more attributes, as opposed to ORDER BY which changes the order of rows presented
SELECT first_name
FROM employees
GROUP BY first_name HAVING Count(first_name) >1
Back
SELECT DISTINCT
Front
SELECT DISTINCT column_name
FROM table_name;
Back
Default ports to secure SQL server
Front
1433 and 1434
Back
First normal form
Front
Eliminate repeating groups
Requirements:
-cells may not have more than one piece of data
-each record must be unique
--> both of these are solved by primary key
Back
Referential integrity
Front
Ensures that all relationships within a database are maintained throughout updates—enforced through the foreign key constraint
Back
IN
Front
Allows you to select multiple statements in a WHERE query — shorthand for multiple OR statements
SELECT column_name
FROM table_name
WHERE column_name IN (value1, value2);
also works with NOT IN
Back
Second normal form
Front
Eliminate redundant data
Requirements:
-record should only depend on primary key
--> separate tables if not
Back
DDL clauses
Front
USE, CREATE, ALTER, DROP, DELETE TRUNCATE
Back
Adding duplicate IDs to a db
Front
Permitted as long as the ID is not specified PRIMARY KEY
Back
DML clauses
Front
SELECT, UPDATE, INSERT, DELETE, MERGE
Back
Indexes, foreign keys, and stored procedures _________ when added
Front
Improve performance
Back
BETWEEN
Front
SELECT column_name
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
Back
MIN and MAX
Front
SELECT MAX(column_name)
FROM table
WHERE condition;
SELECT MIN(column_name)
FROM table
WHERE condition;
Back
INSERT INTO
Front
INSERT INTO table_name(column1, column2)
VALUES (value1, value2);
Back
GROUP BY
Front
A SQL clause that formats results when combined with any of the aggregate functions in a SELECT statement. Aggregate functions will not work without GROUP BY.
Back
Create a primary key
Front
CREATE TABLE name (column 1 INT PRIMARY KEY)
Back
AND
Front
SELECT column_name
FROM table_name
WHERE condition1
AND condition 2;
Back
Cascading deletes remove data but not ________
Front
database objects
Back
PRIMARY KEY constraint
Front
Ensures all values in columns are unique and not null—a combination of the UNIQUE and NOT NULL constraints
Each table can only have one primary key constraint
Back
DEFAULT constraint
Front
Sets a default value for columns where no value is specified
Back
Trigger
Front
A trigger is a stored procedure that automatically fires when an action is taken.
Back
Add columns into table for employee info
Front
INSERT INTO employee (id, first_name, last_name)
Back
NOT NULL constraint
Front
Ensures that no values in columns are NULL
Back
Transaction syntax
Front
BEGIN TRANSACTION ColumnClause
DELETE from condition WHERE condition
COMMIT TRANSACTION ColumnClause;
BEGIN TRANSACTION VolunteerDelete
DELETE from Volunteer WHERE id = 13
COMMIT TRANSACTION VolunteerDelete;
Back
WHERE
Front
SELECT column_name
FROM table_name
WHERE condition;
Back
OR
Front
SELECT column_name
FROM table_name
WHERE condition1
OR condition2;
Back
Add values into table columns
Front
VALUES (3424, hector, smith)
Back
NULL
Front
SELECT column_name
FROM table
WHERE column_name IS NULL;
SELECT column_name
FROM table
WHERE column_name IS NOT NULL;
Back
Subquery
Front
A query that is inside another select or action query.
Back
UPDATE
Front
UPDATE table_name
SET column1 =value1, column2 =value2
WHERE condition;
The WHERE is especially important after SET before it indicates which cell is replaced . UPDATE employee SET last_name = 'jones' WHERE employee__id = 1314
Back
NOT
Front
SELECT column_name
FROM table_name
WHERE NOT condition1;
Back
UNIQUE constraint
Front
Ensures all values in columns are unique
Back
CHECK constraint
Front
Limits the range of values that can go in a column or table
If a CHECK is defined for a table, it can impact values in columns based on existing columns
Back
Create a composite primary key
Front
CREATE TABLE name (column1 INT column2 varchar(20) column 3 INT)
PRIMARY KEY (column 1, column3)
Back
Add columns from a previous table into the new table
Front
The INSERT INTO clause must still be first, same in standard syntax.
INSERT INTO employee
SELECT *
FROM old_employee
Back
Function
Front
aggregate operations return a single value, calculated from values in a column.
Useful aggregate functions:
AVG() - Returns the average value
COUNT() - Returns the number of rows
FIRST() - Returns the first value
LAST() - Returns the last value
MAX() - Returns the largest value
MIN() - Returns the smallest value
SUM() - Returns the sum
Back
Functionally dependent
Front
The relationship between column values and their primary key value
Back
operators used with WHERE
Front
>, <, =, <=, >=, <>, _
BETWEEN, LIKE, IN
Back
Two keys that establish relationship between tables
Front
primary + foreign
Back
SELECT
Front
SELECT column_name(s) FROM table_name;
Back
Third normal form
Front
Eliminate columns that are not dependent on only the primary key
Requirements:
-eliminate transitive dependencies
Back
Create a view
Front
CREATE VIEW vwPlanets
AS
SELECT planets, diameter
Back
Create a table that saves employee info
Front
CREATE employee (id INT, first_name varchar(20), last_name varchar (20))
Back
Index
Front
object that speeds select queries from a db
Back
COUNT DISTINCT
Front
SELECT COUNT (DISTINCT column_name)
FROM table_name;
Back
ORDER BY
Front
Alters the order that column results appear SELECT column_name
FROM table_name
ORDER BY column_name;
[ASC or DESC to sort]
Back
Section 2
(9 cards)
Physical database design
Front
Process of storing data to achieve efficient access and built for a specific DBMS
Back
Conceptual database design
Front
High level of data design at entity-relationship level
Back
Transaction
Front
BEGIN TRANSACTION transactionName
DELETE operation
COMMIT TRANSACTION transactionName
Back
DROP TABLE
Front
removes a table object from the database
Back
Logical database design
Front
Organizing data according to a specific model but independent of a particular DBMS
Back
Front
Back
GROUP BY vs. ORDER BY
Front
ORDER BY orders results by a parameter
GROUP BY displays aggregates by a column
Back
TRUNCATE TABLE
Front
removes from a database, leaving empty space for reuse
Back
Application design
Front
Design of user interface and application programs that use and process the database