Download presentation
Presentation is loading. Please wait.
Published byAmi Hensley Modified over 9 years ago
1
CS 101 – Nov. 9 Text software issues (continued) –Readability –Fonts Database concepts –Relationships –Queries
2
Readability First, need to measure: –Words per sentence –Syllables per word How to Write Plain English by Flesch: 206.835 – 84.6*spw– 1.015*wps 90’s = fifth grade 30’s = college level
3
Fonts Font = style of printing –Typeface –Point size –Ex. Times 10, Helvetica 12 Fonts can be distinguished by –Sarif or sans sarif –Proportional or non-proportional
4
Font types Sarif = has feet Sans sarif = no feet –Look at: i, h, n, r, … (but not t!) Proportional = width of characters changes Non-proportional = all have same width
5
Access review Purpose: Manage data Parts of a database –If your database has only 1 table, you are better off using Excel Relationship between tables? –None –One-to-one –One-to-many (most common) –Many-to-many
6
Table design What fields to we need? –Age? store birth date –GPA? store credits and quality points –What year? store date of admission Store data in its smallest parts (e.g. address) Calculated fields don’t belong in table!
7
Queries Usually we ask about info from 2+ tables. By default, a query will perform an operation called a Cartesian Product, which gives all possible combinations. Ex. Name and City tables: Name Bob Mary Ken City Miami Pittsburgh
8
Cartesian Product Given 2 sets, find all possible ordered pairs. –Analogously for more than 2 sets. Great example: choosing a menu. –Appetizer –Entrée –Dessert Unfortunately, most DB queries are not like this! We get too many results.
9
Relationships We want to tell Access that there is a relationship between the tables, so we can create meaningful query. One-to-many is most common –“Each city has one or more employees.” –Now, query will return 3 results instead of 6: MiamiBob PittsburghMary Ken
10
One-to-One Can be useful if some information is confidential. What if we didn’t have any relationship? Empl #NamePosition 101SmithWelder 102Jonescarpenter Empl #Salary 10218,000 10117,000
11
1-1 Query When you combine tables that have a 1-1 relationship: Access will look for fields that are the same, and use this as a filter. –In previous example, we’ll have 2 results instead of 4. Employee 101’s information Employee 102’s information –Let’s look at another example.
12
What happens when we “join” these 1-1 tables? First nameLast namePositionCity BobFulleraccountantChicago BobDanielscashierGreenville BobDanielsaccountantIndianapolis AliceAndrewsgardenerGreenville First nameLast nameSalaryBirthday BobDaniels51,0007/1/67 ElenaCarlson21,0009/1/89 AliceAndrews81,0008/1/78
13
FirstLastPositionCitySalaryBirthday BobDanielscashierGreenville51,0007/1/67 BobDanielsaccountantIndianapolis51,0007/1/67 AliceAndrewsgardenerGreenville81,0008/1/78 First nameLast namePositionCity BobFulleraccountantChicago BobDanielscashierGreenville BobDanielsaccountantIndianapolis AliceAndrewsgardenerGreenville First nameLast nameSalaryBirthday BobDaniels51,0007/1/67 ElenaCarlson21,0009/1/89 AliceAndrews81,0008/1/78
14
Relationship summary When you have 2+ tables, there is almost always a relationship They share one field in common. –Can you tell what it is? Ex. Customers & Orders Ex. Publishers & books Ex. Students & Class roster
15
Example
16
One-many Relationships Referential integrity –Keep related records consistent –Cascade delete: allow deletion of “one” –Cascade update: allow update of “one” For example, changing someone’s CustomerID.
17
Many-to-many Ex. Customers to products Implement as 2 one-to-one “Order details” table Think of possible queries based on the 5 tables given in handout.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.