












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













Create tables - Insert records into tables - Query the tables
Sort - Hash Indexing - Buffer Manager - Relation and Attribute Catalog definitions
RelDesc: attributes, indexes on a relation typedef struct { char relName[MAXNAME]; // relation name int attrCnt; // number of attributes int indexCnt; // number of indexed attrs } RelDesc; class RelCatalog : public HeapFileScan { public: // get relation descriptor for a relation const Status getInfo(const string & rName, RelDesc& record); // add information to catalog const Status addInfo(RelDesc & record); …
AttrDesc: Attribute Description typedef struct { char relName[MAXNAME]; // relation name char attrName[MAXNAME]; // attribute name int attrOffset; // attribute offset int attrType; // attribute type int attrLen; // attribute length int indexed; // TRUE if indexed } AttrDesc; class AttrCatalog : public HeapFileScan { public: // get attribute catalog tuple const Status getInfo(const string & rName, const string & attrName, AttrDesc &record); // add information to catalog const Status addInfo(AttrDesc & record); // get all attributes of a relation const Status getRelInfo(const string & rName, int &attrCnt, AttrDesc *&attrs); …
INSERT INTO RELNAME(ATTRNAMELIST) VALUES (VALUELIST)
const Status Updates::Insert(const string & relation, const int attrCnt, const attrInfo attrList[] ) typedef struct { char relName[MAXNAME]; // relation name char attrName[MAXNAME]; // attribute name int attrType; // INTEGER, FLOAT, or STRING int attrLen; // length of attribute in bytes void *attrValue; // ptr to binary value (used // by the parser for insert into // statements) } attrInfo;
INSERT INTO RELNAME(ATTRNAMELIST) VALUES (VALUELIST)
const Status Updates::Insert(const string & relation, const int attrCnt, const attrInfo attrList[] ) typedef struct { char relName[MAXNAME]; // relation name char attrName[MAXNAME]; // attribute name int attrType; // INTEGER, FLOAT, or STRING int attrLen; // length of attribute in bytes void *attrValue; // ptr to binary value (used // by the parser for insert into // statements) } attrInfo;
The “WHERE relation.attr > 2” kind - 2 access methods - File Scan - Index Scan - “Optimization” - Hash Indexing used - So index scan, when index and equality - Issues - No WHERE clause, then attribute list is NULL - Result stored in result relation
static Status Select(const string
result, // name of the output relation const int projCnt, // number of attributes in the projection const attrInfo projNames[], // the list of projection attributes const attrInfo *attr, // attribute used in the selection predicate const Operator op, // predicate operation const void *attrValue); // literal value in the predicate
Sort Merge
80% of available buffers - n = number of tuples that can fit on the k buffers - Use Heapfilescan, storing n tuples at a time - Sort tuples, store in temporary files [runs] - Merge all temporary files, upto k Heapfilescans - Issues
attrcat and relcat are relations - You must add data for themselves into the tables - 2 records into relcat - A record for each attribute of the relations into attrcat [ = 3 + 6 ]
1. insert.cpp : Inserting tuples 2. query.h : Selects and the joins 3. select.cpp : Call the appropriate select algorithm. 4. scanselect.cpp : Select using a file scan 5. indexselect.cpp : Index selection 6. join.cpp: Pick the appropriate join algorithm 7. snl.cpp : Simple nested loop algorithm. 8. inl.cpp : Index nested loops algorithm 9. smj.cpp : sort merge join 10. dbcreate.cpp : Bootstrapping the catalogs