{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# The Relational Model\n", "\n", "- The relational model is a mathematical *abstraction* used to describe\n", "how data can be structured, queried and updated.\n", "\n", "- It is based on *set theory*.\n", "\n", "- It can be *implemented* in many different ways.\n", "\n", "- When it is implemented by storing relations on disk files, we have a *relational database*.\n", "\n", "- Functional programming languages such as Python naturally express many aspects of the relational model.\n", "\n", "- This is one of the reasons they are very useful for data science." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Overview\n", "\n", "1. The formal definition of the relational model\n", "\n", "2. Representing relations in Python using collections of tuples\n", "\n", "3. Querying relational data using Python set comprehensions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## An Example Relational Dataset\n", "\n", "The following slides use relations to describe:\n", "\n", "- students, \n", "- the courses they are taking \n", "- the prerequisites of courses\n", "- their grades\n", "- which department they are in" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "slideshow": { "slide_type": "slide" } }, "outputs": [ { "data": { "text/html": [ "
\n", " | name | \n", "student_number | \n", "course_id | \n", "department | \n", "
---|---|---|---|---|
0 | \n", "Smith | \n", "17 | \n", "1 | \n", "CS | \n", "
1 | \n", "Brown | \n", "18 | \n", "2 | \n", "CS | \n", "