HW6: Sort-Merge Join Instructors: Winston Hsu, Hao-Hua Chu Fall 2009 Architecture of a DBMS Query Query Optimization and Execution Relation Operators(Join) File and Access Methods Buffer Management Disk Space Management DB Sort-Merge Join Example sid sname sid sname sname BID sname BID 31 A 31 A A 112 C 118 28 E 22 A A 168 B 112 22 A 36 C B 112 A 112 36 C 44 D B 101 A 168 44 D 28 E C 118 B 101 Sort by sname Get the first tuples Merge sid sname BID 31 A 112 31 A 168 22 A 112 22 A 168 36 C 118 Some APIs • Sort constructor(… outfile …) – Outfile : Name of sorted heapfile should be distinct • HeapFile constructor • HeapFile->openScan() – Followed by scan->getNext() and get the firstRecord • tupleCmp() : compare tuples • Scan->position() – Position the scan cursor to the record with the given rid. Other • Output format: if recA = recA ,then write recA recA • If there are any questions, you can post them on ptt.cc / CSIE_DBMS. • Deadline: 23:59 Jan 6 (Wednesday), 2010 Heapfile “Database Management Systems, Third Edition” by Ramakrishnan and Gehrke