CS4432Notes 14 Naïve Implementation Relations stored in files (ASCII) e.g., relation Students is in /usr/db/Students Smith # 123 # CS Jones # 522 # EE.... Students CS # Fuller Labs EE # Atwater Kent PH # Olin Hall.... Depts
CS4432Notes 16 Sample Query select Students.name,Depts.office from Students,Depts where Students.dept = Depts.name and Students.id > 300 # Smith # 123 # CS # CS # Fuller Labs Smith # 123 # CS # EE # Atwater Kent Smith # 123 # CS # PH # Olin Hall Jones # 522 # EE # CS # Fuller Labs Jones # 522 # EE # EE # Atwater Kent Jones # 522 # EE # PH # Olin Hall
CS4432Notes 17 Simple Query Execution Process To execute “ select * from R where condition ”: (1) Read dictionary to get R attributes (2) Read R file, for each line: (a) Check condition (b) If OK, display
CS4432Notes 18 Yet Another Execution To execute “ select A,B from R,S where condition ”: (1) Read dictionary to get Students and also Depts attributes (2) Read Students file, for each line: (a) Read Depts file, for each line: (i) Create join tuple (ii) Check condition (iii) Display if OK
CS4432Notes 110 What’s wrong ? Layout ? Tuple layout on disk Example: - Change string from ‘Cat’ to ‘Cats’ and we have to rewrite file - ASCII storage is expensive - Deletions are expensive
CS4432Notes 111 What’s wrong ? Search ? Search expensive; no indexes e.g.,- Cannot find tuple with given key quickly - Always have to read full relation
CS4432Notes 112 What’s wrong ? Brute force query processing e.g., select * from R,S where R.A = S.A and S.B > 1000 - Do select first? - More efficient join?
CS4432Notes 113 What else is wrong ? Missing ? No buffer manager : –Need caching No concurrency control: –Multiple users access and modify same data ? No reliability: – Lose data? leave operations half done ? No security: –-File system insecure? Too coarse security?
CS4432Notes 114 System Structure Buffer Manager Query ParserUser User TransactionTransaction Manager Strategy Selector Recovery ManagerConcurrency Control File ManagerLogLock TableM.M. Buffer Statistical Data Indexes User DataSystem Data
CS4432Notes 115 Course Overview File & System Structure Records in blocks, dictionary, buffer management,… Indexing & Hashing B-Trees, hashing,… Query Processing Query costs, join strategies,… Crash Recovery Failures, stable storage,… Concurrency Control Correctness, locks,… Transaction Processing Logs, deadlocks,… Additional Topics If time permits …