-trees corn silag corn silag mg corn silag fat almond hul almond hul ca almond hul rfv almond hul almond hul almond hul mg almond hul fat relational databases are often called sql databases sql stands for system query language sql is language for querying relational databases sql can be used to build temporary tables like the one in sect the sql statement to build this table would be written as select feed feednumfeed namefeedattribtype namefeedattribute value where feed feedid feedattribute feedid and feedattribute feedattribtypeid feedattribtype feedattribtypeid this sql statement is known as join of three tables because three tables will be joined together to form the result it is up to the relational database to translate this query into commands that read the three tables and efficiently construct new temporary table as the result of the join if we were to implement our own relational databasethe join operation for these three tables might be programmed similarly to the code appearing in sect don' be misled relational databases don' program specific joins like this onebut the joining of the three tables might be functionally equivalent to this code the entire program is available as joinquery py on the text' website the readfield function here in the text is abbreviated for spacebut reads any type of field from table file the join algorithm picks one of the tables and read it from beginning to end in this casethe feedattribute table is read from beginning to end for each feed attributethe matching feed id from the feed table must be located in the code in sect this involves readingon averagehalf the feed table to supply the feed number and feed name for each line of the query likewiseto supply the feed attribute nameon average half the feedattribtype table is read to supply the feed attribute name for each line of the query output the complexity of this operation is ( *mwhere is the number of records in feedattribute tbl and is the maximum of the number of records in feedattribtype tbl and feed tbl this is ( performance if is roughly equivalent to whether the two are roughly equivalent or notthe performance of this queryeven on our small sample tableis not great it takes about to run the query as written on ghz intel core processor with gb of ram and solid state hard drive programming the joining of tables import datetime def readfield(record,coltypes,fieldnum)this copy belongs to 'acha