1/197
Looks like no tags are added yet.
What is a database?
A collection of related data representing a real-world scenario.
What is a DBMS?
Software for storing, querying, managing, and analyzing a database.
What is a data model?
A way to represent a real-world scenario inside a database.
What three concepts form the basis of a data model?
Entities, attributes, and relationships.
What is the difference between a database and a DBMS?
A database is the stored data; a DBMS is the software that manages it.
Why use a DBMS instead of separate application files?
To support structured storage, efficient queries, and shared data management.
What is a query?
A request to retrieve or manipulate data in a database.
What are the two broad sides of CS564?
Database application/design and DBMS system internals.
What is an entity in ER modeling?
A distinguishable real-world object of interest, such as a Student.
What is an entity set?
A collection of entities of the same type.
What is an attribute?
A property describing an entity or relationship.
What is a relationship in an ER model?
An association among entities.
What does ER stand for?
Entity–Relationship.
What is conceptual database design?
Modeling entities, attributes, and relationships before implementing tables.
What is an ER diagram used for?
A graphical representation of a database's conceptual structure.
What is a binary relationship?
A relationship involving two entity sets.
What is a multiway relationship?
A relationship involving more than two entity sets.
What is a one-to-one relationship?
Each entity on either side is associated with at most one on the other.
What is a many-to-one relationship?
Many entities on one side may relate to one entity on the other.
What is a many-to-many relationship?
Multiple entities on each side may relate to multiple on the other.
What do arrows indicate in ER relationship notation?
Key constraints on the relationship, such as at-most-one participation.
Why do ER diagrams use roles?
To distinguish multiple uses of the same entity set in one relationship.
Why avoid multi-valued lists in a relational cell?
Relational attributes are expected to hold atomic values.
What comes after conceptual design in building a database?
Translate the ER model into a relational schema and implement it.
What is a relation?
A table consisting of tuples and attributes.
What is a tuple?
One row in a relation.
What is an attribute? (Lecture 3)
One named column in a relation.
What is an attribute domain?
The permitted atomic data type or set of values for an attribute.
How is an entity set translated into a relation?
Make a table with a column for each attribute and the entity key.
How is an ER relationship normally translated into tables?
Create a relation with participating entity keys and relationship attributes.
When can a relationship be combined into an entity table?
When key constraints make storing a foreign key in one entity table appropriate.
What is a key?
An attribute set that uniquely identifies an entity or tuple.
What is a candidate key?
A minimal attribute set that uniquely identifies a tuple.
Can an entity set have several candidate keys?
Yes; different attribute sets can each uniquely identify entities.
What does a primary key do?
Designates the chosen unique identifier for tuples.
What is a weak entity set?
An entity set whose identification depends on an owner entity set.
How is a weak entity identified?
By its partial key together with the owner's key.
What does an ISA relationship represent?
A subclass is a specialized kind of superclass.
What does a subclass inherit?
Attributes and relationships of its superclass.
What is the object-oriented translation of subclasses?
One relation per class containing inherited and local attributes.
What is the ER-style translation of subclasses?
One superclass table and subclass tables containing keys and subclass attributes.
What is the single-table NULL translation of subclasses?
One relation with columns for every subclass and NULLs where inapplicable.
What is a drawback of the single-table subclass approach?
Many NULLs with potentially different meanings.
What is the difference between at-most-one and exactly-one participation?
At-most-one permits zero; exactly-one requires one.
What is a database constraint?
A condition that all valid database states must satisfy.
What does SQL stand for?
Structured Query Language.
What is the basic SQL query pattern?
SELECT columns FROM tables WHERE row condition.
What does SELECT specify?
The output expressions or columns.
What does FROM specify?
The input table or tables.
What does WHERE specify?
Conditions filtering candidate rows.
What does SELECT * mean?
Return all columns of the selected rows.
How can you rename a column in a query result?
Use AS with an alias in SELECT.
What are SQL aliases used for?
Renaming output columns or referring to tables concisely.
Can SELECT contain computed expressions?
Yes; expressions can calculate output values.
How do AND and OR differ in WHERE?
AND requires both predicates; OR requires at least one.
What does NOT do in a WHERE condition?
Negates a Boolean predicate.
What does SQL LIKE do?
Matches strings against a pattern.
What does % mean in a LIKE pattern?
Any sequence of zero or more characters.
What does _ mean in a LIKE pattern?
Exactly one character.
How do you match strings beginning with A?
WHERE column LIKE 'A%'.
What is the role of DISTINCT?
Remove duplicate result rows.
Why can an SQL query return duplicate rows?
SQL normally uses bag rather than set semantics.
How are text literals typically written in SQL?
With single quotation marks.
How do you query more than one table in SQL?
List multiple tables in FROM and relate them with WHERE conditions.
What is a Cartesian product of two relations?
Every possible pair of rows from the two relations.
What happens if a multi-table query lacks a join condition?
It can produce an unintended Cartesian product.
How do you disambiguate a shared column name?
Prefix it with a table name or alias, such as R.id.
What is a join condition?
A predicate matching related rows across tables.
How can indexes improve a multi-table query?
Quickly locate rows satisfying filters and matching join keys.
What does FROM Product AS P do?
Assigns the tuple variable or alias P to Product.
What is a self-join?
Joining a table to itself using separate aliases.
What does COUNT(*) compute?
The number of rows in a group or result.
What does AVG(column) compute?
The average of non-NULL values in that column.
What do MIN and MAX compute?
The smallest and largest non-NULL values.
What does SUM(column) compute?
The sum of non-NULL values.
What is the purpose of GROUP BY?
Partition rows into groups for aggregate calculations.
What is HAVING used for?
Filter groups after aggregation.
How does HAVING differ from WHERE?
WHERE filters input rows; HAVING filters groups.
What is the standard aggregation clause order?
SELECT; FROM; WHERE; GROUP BY; HAVING.
How would you find the average price per store?
SELECT store, AVG(price) FROM Sells GROUP BY store.
How do you keep only stores with AVG(price) > 20?
GROUP BY store HAVING AVG(price) > 20.
What does SQL NULL represent?
A missing, unknown, or inapplicable value.
Does x = NULL test for a NULL value?
No; use x IS NULL.
How do you find rows whose column is not NULL?
WHERE column IS NOT NULL.
What is SQL's three-valued logic?
Predicates can be TRUE, FALSE, or UNKNOWN.
How does WHERE treat UNKNOWN?
Only TRUE rows pass the filter.
What is a subquery?
A query nested inside another SQL statement.
What does IN (subquery) test?
Whether a value belongs to the subquery's result set.
What does EXISTS (subquery) test?
Whether the subquery produces at least one row.
What does NOT EXISTS test?
Whether a subquery produces no rows.
What does comparison with ANY mean?
The comparison holds for at least one returned value.
What does comparison with ALL mean?
The comparison holds for every returned value.
What is a correlated subquery?
A subquery that refers to values from its surrounding query.
What does CREATE TABLE do?
Define a new relation and its column constraints.
What does DROP TABLE do?
Remove a table definition from the database.
What does INTEGER specify?
An integer-valued column type.
What does VARCHAR(n) specify?
A varying-length character string up to length n.
What does CHAR(n) specify?
A fixed-length character string of length n.
What does NOT NULL require?
Each row must have a non-NULL value in that column.
What does UNIQUE enforce?
Values of the constrained key are not repeated, subject to NULL rules.