alter table, add column, insert into, update-set-(where), delete
from-(where)
Queries
Requests made to the DBMS for specific info from the DB
Can be nested
Joins
Combines rows from different tables into a single result based on related
columns
4 types: inner, left, right, full outer join
On delete: handles when a row with a foreign key is deleted
Set null: the affected row will have the related values set to NULL
Cascade: delete the entire row
Triggers
A block of SQL that defines a certain action that should happen when a
certain operation gets performed on the DB
Entity Relationship (ER) Diagrams
DB schema
All the tables & attributes & relationships
ER diagram
Middleman between data storage requirements (business requirements) and
the actual DB schema
Entity
An object we want to model & store information about
Attributes
Specific pieces of information about an entity
Primary key
An attribute(s) that unique identify an entry in the DB table
Composite attribute
An attribute that can be broken up into sub-attributes
Multi-valued Attribute
An attribute that can have more than one value
Derived Attribute
An attribute that can be derived from other attributes
Can also not track this in the actual DB
Multiple Entities
More than one entity can be defined in the diagram
Relationships
Defines a relationship between two entities
Total Participation
All members must participate in the relationship
Relationship Attribute
An attribute about the relationship
Relationship Cardinality
The number of instances of an entity from a relation that can be
associated with the relation
One-to-one, one-to-many, many-to-many
Weak Entity
An entity that cannot be uniquely identified by its attributes alone
Identifying relationship - A relationship that serves to uniquely identify
the weak entity
Data requirements (describes all of the different data and the relationships
between them) → ER diagram → DB schema
Converting ER diagram to DB schema
Mapping of Regular Entity Types a. For each regular entity create a relation
(table) that includes all the simple attributes of that entity
Mapping of Weak Entity Types a. For each weak entity type create a relation
(table) that includes all simple attributes of the weak entity b. The primary
key of the new relation should be the partial key of the weak entity plus the
primary key of its owner
Mapping of Binary 1:1 Relationship Types a. Include one side of the
relationship as a foreign key in the other b. Favor total participation
Mapping of Binary 1:N Relationship Types a. Include the 1 side’s primary key
as a foreign key on the N side relation (table)
Mapping of Binary M:N Relationship Types a. Create a new relation (table)
whose primary key is a combination of both entities’ primary keys b. Also
include any relationship attributes