SQL Database Course
- 56Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What is a database?
Any collection of related information.
Or swipe the card
56 cards
What is a database?
Any collection of related information.
What is a Database Management System (DBMS)?
A special software program that helps users create and maintain a database on a computer.
What does CRUD stand for?
Create, Read (Retrieve), Update, Delete.
What is a relational database?
A database that organizes data into one or more tables with rows and columns, where each row has a unique key.
What is a non-relational database?
Any database that does not use the traditional table structure; it can be document-based, key-value, graph, etc.
What is a primary key?
An attribute that uniquely identifies each row in a table. It must be unique and not NULL.
What is a foreign key?
An attribute in one table that stores the primary key of another table, creating a relationship between them.
What is a surrogate key?
A primary key that has no real-world meaning, typically an auto-incrementing number.
What is a natural key?
A primary key that has a real-world mapping, such as Social Security Number.
What is a composite key?
A primary key that consists of two or more columns, where no single column can uniquely identify a row.
What does the INT datatype store?
Integer (whole number) values.
What does the DECIMAL(M,N) datatype store?
Decimal numbers with M total digits and N digits after the decimal point.
What does VARCHAR(n) store?
A string of text with a maximum length of n characters.
What does the DATE datatype store?
A date value in the format YYYY-MM-DD.
What is the DEFAULT constraint used for?
It sets a default value for a column when no value is provided during insertion.
What does the AUTO_INCREMENT keyword do?
Automatically generates a unique number for each new row, typically used for primary keys.
How do you insert a new row into a table?
INSERT INTO table_name VALUES (value1, value2, ...);
How do you update existing rows in a table?
UPDATE table_name SET column = value WHERE condition;
How do you delete rows from a table?
DELETE FROM table_name WHERE condition;
What is the purpose of the SELECT statement?
To retrieve data from one or more tables.
How do you order query results?
Use ORDER BY column_name [ASC|DESC];
How do you limit the number of results in a query?
Use LIMIT number;
What does the DISTINCT keyword do?
It returns only distinct (different) values from a column.
How do you filter rows with a condition?
Use WHERE clause with comparison operators (=, <, >, <=, >=, !=) and logical operators (AND, OR).
What is the IN operator used for?
It checks if a value matches any value in a list.
What is the COUNT function?
Returns the number of rows that match a condition.
What is the AVG function?
Returns the average value of a numeric column.
What is the SUM function?
Returns the sum of a numeric column.
What does GROUP BY do?
Groups rows that have the same values in specified columns, often used with aggregate functions.
What is a wildcard in SQL?
Special characters used with the LIKE operator to match patterns: % (any number of characters) and _ (single character).
What does UNION do?
Combines the result sets of two or more SELECT statements into a single list.
What is an INNER JOIN?
Returns rows when there is a match in both tables based on the join condition.
What is a LEFT JOIN?
Returns all rows from the left table and matching rows from the right table; NULLs if no match.
What is a RIGHT JOIN?
Returns all rows from the right table and matching rows from the left table; NULLs if no match.
What is a FULL OUTER JOIN?
Returns all rows when there is a match in either table; returns NULL for non-matching rows. Not directly supported in MySQL.
How do you write a nested query (subquery)?
Place one SELECT statement inside another, often with IN, =, or EXISTS.
What does ON DELETE SET NULL do?
When a referenced row is deleted, the foreign key column(s) are set to NULL.
What does ON DELETE CASCADE do?
When a referenced row is deleted, the rows with that foreign key are also deleted.
What is a trigger?
A block of SQL code that automatically executes when a specified event (INSERT, UPDATE, DELETE) occurs on a table.
How do you change the delimiter in MySQL?
Use DELIMITER // (or another symbol) to temporarily change the statement delimiter, then change it back.
What is an entity in an ER diagram?
An object we want to model and store information about, represented by a rectangle.
What is an attribute in an ER diagram?
A specific piece of information about an entity, represented by an oval.
What is a composite attribute?
An attribute that can be divided into smaller sub-attributes, e.g., Name into First Name and Last Name.
What is a multi-valued attribute?
An attribute that can have multiple values, e.g., Clubs for a student.
What is a derived attribute?
An attribute whose value can be derived from other attributes, e.g., Age from Birth Date.
What is a relationship in an ER diagram?
An association between two or more entities, represented by a diamond.
What does total participation mean in an ER diagram?
Every entity in the set must participate in the relationship (double line).
What does partial participation mean?
Not all entities need to participate in the relationship (single line).
What is relationship cardinality?
The number of instances of one entity that can be associated with instances of another entity, e.g., 1:1, 1:N, M:N.
What is a weak entity?
An entity that cannot be uniquely identified by its own attributes alone; it depends on another entity.
What is an identifying relationship?
A relationship that helps uniquely identify a weak entity; shown with a double diamond.
How do you map a regular entity to a table?
Create a table with all simple attributes; the primary key becomes the table's primary key.
How do you map a weak entity to a table?
Create a table with all simple attributes; the primary key is the partial key of the weak entity plus the primary key of the owner entity.
How do you map a 1:1 relationship?
Add the primary key of one entity as a foreign key in the other entity's table; favor the side with total participation.
How do you map a 1:N relationship?
Add the primary key of the '1' side as a foreign key in the table of the 'N' side.
How do you map an M:N relationship?
Create a new table with a composite primary key consisting of the primary keys of both entities, plus any relationship attributes.

Ask anything
We've read this whole study set, so questions about it get the best answers.