Database is a collection of structured data. Captures an abstract representation of the domain of an application.
Organised as records in tables/relations, and there are relationships between records. Each relation has a set of attributes, where each attribute has a type.
Schema is a structural description of relations in a database.
Relational model was proposed in 1970 by Ted Codd. Database abstraction to avoid maintenance.
structure: definition of relations and concepts
integrity: ensure that contents satisfy constraints
manipulation: access and monitor contents
Note: Based on bags (duplicates) and not sets (no duplicates)
Data Model: set of constructs to describe organisation of the data (i.e. tables, graphs, triples, relational, key-value)
Conceptual Schema: description of particular collection of data using given data model. (i.e. schema)
Declarative Querying and Querying Processing
Data Independence: separating what from how
Data Definition Language vs Data Manipulation Language
Grouping atomic transactions
Moving between consistent states
Isolates from parallel execution of other actions
Queries operate on relations to produce relations.
Picks specific rows (by expressing constraints)
Picks specific columns (by specific columns)
Compose the rows and columns
Combines relations horizontally by using a cross product. The tuples need to have the same attributes.
Finds difference between sets. The tuples have to have the same attributes.
Doesn’t add any expressive power to the language as it can be expressed with two difference operators. The tuples have to have the same attribute.
Generates a relation that has all possible combinations of tuples from the input relations.
Generates a relation that contains all tuples that are combinations of two tuples with a common attribute.
Returns a single value from a bag of tuples
(i.e. AVG, MIN, MAX, SUM, COUNT)
Performs a calculation across a set of tuples related to a single row
(i.e. OVER(PARTITION BY cid)) (i.e. RANK() OVER (PARTITION BY .. ORDER BY grade ASV))