The database is Luis Rocha’s Chinook Database, modified for use with Python. I will provide this database.

computer science

Description

Assignment due November 3

RDBMS and Database

The RDBMS for this project is a Python program that you and your team will implement.

The database is Luis Rocha’s Chinook Database, modified for use with Python. I will provide this database.

Platforms

Python 3.6.8.

Loading the Database

Download the database file Chinook_Python.py and place it in directory where you will develop your Python code. The database can be loaded with the following command:

from Chinook_Python import *

You will find variables named Artist, Album, Customer, etc. containing sets of namedtuple objects.

Note: an earlier version of Chinook_Python.py did not export the InvoiceLine relation by default. You can import it explicitly (e.g., from Chinoook_Python import InvoiceLine), or use the link above to download an updated version.

Relational Operators

Task: 1 Implement the following functions in Python:

  • select(relation, predicate)
  • project(relation, columns)
  • rename(relation, new_columns=None, new_relation=None)
  • cross(relation1, relation2)
  • theta_join(relation1, relation2, predicate)
  • Implement natural_join(relation1, relation2).

The predicate for select() should be a function that takes a single namedtuple as an argument and returns True or False.

The predicate for theta_join() should take two namedtuples and return a bool.

The new_columns and new_relation parameters to rename() are optional. if neither argument is provided, return the original relation.

 

 

Queries

The file queries.py contains four variations of the query:

  1. Combining ? and ⨯ to implement ?-join
  2. Performing ? after ?-join
  3. Performing ? before ?-join
  4. Natural join (Run this If you did the extra credit.)

All of the queries above should return the following set:

{Result(Title='Blood Sugar Sex Magik'),

 Result(Title='By The Way'),

 Result(Title='Californication')}

Task 2: When the relational operators are implemented and the queries above work correctly, write code to run the following query from.

Names of the support representatives whose customers bought tracks in “Purchased AAC audio file” format.

Performance Measurement

As a rough approximation of the processing required for each query, instrument your functions to measure the cardinality of the result set for each relational operator. When a query completes, print the total number of tuples returned during processing.


Related Questions in computer science category