Databases CS 110 Fall 2005 Homework Read “Introduction to Access” from text Next Tuesday: turn in index card with three questions about reading Databases Become common in 1970s If spreadsheets crunch numbers… databases crunch information Aren’t numbers information? Managing Information What is information? • How do I get to the Rotunda from here? • Is there a baby panda at the zoo? • When does the next bus come by? • What’s your phone number? These aren’t numerical questions Logical Relationships How do I get to the Rotunda from here? • Consider taking all actions from here 1. 2. 3. Where do I end up? Am I at the Rotunda? Consider taking all actions from there 1. Where do I end up? 2. Am I at the Rotunda? 3. Repeat… Logical Relationships Consider taking all actions from here 1. Where do I end up? 2. Am I at the Rotunda? 3. Consider taking all actions from there 1. 2. 3. Where do I end up? Am I at the Rotunda? Repeat… Logical Relationships I H G C E A F B D A B C D E F G H I B, C A, E A, D, E, H C B, C, F, G E, G E, F C, I H Logical Relationships Is there a baby panda at the zoo? 1. Create list of all animals at the zoo 2. Look for panda in the list 3. Return TRUE or FALSE Logical Relationships When does the next bus come by? 1. 2. 3. 4. Get bus table Organize it by location Sort by time Find entry closest to current time that is in the future What kind of tasks are being repeated? Find affiliated entries that follow specific rules • B must be reachable from A • Name must be panda • Time must be in the future Database Examples Tables – The phone book • A column of names • A column of addresses • A column of phone numbers Database Examples Hierarchical – A family tree • Mary is mother of John • John and Sue are parents of Liz • John and Sue are parents of Laura Derived information • Mary is John’s mom • John does not have another mom • Laura and Liz are siblings Mary John Liz Laura Some Practical Matters Tables and hierarchical databases are monolithic and cumbersome • Updating • Storing • Disseminating Examples Telephone Tables Someone forgot to include the zip code in the phone book • Add a column to the database and mail a new phone book to everyone? • Send an update book which contains only names and zip codes? Family Hierarchy Through remarriage, a person can have multiple mothers • Family tree structure must be adjusted to permit multiple moms • Entire tree must be rewritten • Break the hierarchical organization • Permit everyone to have “parents” and define this in greater detail elsewhere Relational Databases Multiple Tables! • Business records A A A A table table table table of of of of products in inventory customer contact info product suppliers current orders • customers -> products • customers -> products -> supplier • credit card # -> customers -> products Vocabulary Field: a basic fact • There is a customer named Thomas • There is a phone number: 924-HOOS Record: A set of fields • Customer names and phone numbers are related • 924-HOOS --- Thomas Table: A set of records • Students at UVa listed with phone numbers Database: A set of tables Power of Relational DBs Lots of tables with relationships between them Power of Relational DBs Efficiency and flexibility in storing and retrieving information • Easy to add / remove New records and new descriptors • Fast to retrieve • Easy to customize for greater speed • Easy to control security Only one writer at a time (ATM) Exclude some readers (credit reports) Challenges of Relational DBs They become very complex Complexity leads to errors • Stale relationships The area codes for C’ville are updated in one table but not another • Faulty fields in relationships A person is related to two different area codes There’s an art to architecting databases that reduce these problems Commercial Systems Oracle-PeopleSoft SAP Microsoft Siebel Structured Query Language (SQL)