Question: Write a simple relational algebra interpreter in python. A relation is nothing more than a table of fixed-size data rows, which you can store as
Write a simple relational algebra interpreter in python. A relation is nothing more than a table of fixed-size data rows, which you can store as a set of tuples. All the required functionality can reside in a single Table class. Here is the interface you should implement: class Table: definit__(self, name='', fields=tuple(), tups=None): ... # Relational operations: def select (self, field, val): ... def project (self, *fields): ... @staticmethod def join(tabl, tab2): ... def insert (self, *tup): ... def remove(self, field, val): ... # Serialization and text backup def store (self): @staticmethod def restore (fname) :. @staticmethod def read(fname): ... def write(self, fname) : ... name: read/write fields: read only tuples: read only The following methods return a new Table as a result: select, project, join, restore, read. The first three should name the returned table "result". The last two read their names and other data from files. The other methods do not return anything. The first line is the table name, and the second line contains the field (column) names. The rest of the lines represent the tunles (ro ) of the table
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
