190 likes | 397 Views
Class Objectives – 9/10 and 9/12. Learn how to design a small database Understand the goals of a database Understand the terminology of database design Learn how to read a database design diagram Know how to create a database design diagram Implement a small custom database in MS Access
E N D
Class Objectives – 9/10 and 9/12 • Learn how to design a small database • Understand the goals of a database • Understand the terminology of database design • Learn how to read a database design diagram • Know how to create a database design diagram • Implement a small custom database in MS Access • Take a database design diagram and implement the resulting database in MS Access • Create tables • Create attributes with correct data types • Create relationships and referential integrity constraints
Help available • Your books!!!! • Online help via Access and Excel • Google (or other favorite search engine) • Teaching Assistant (Robert Dittmer) • Office hours: Monday andWednesday 10AM-noon • Email: rdittmer@unr.edu • Professor (Dana Edberg) • Office hours: TR 1:15-2:15PM, 4-5PM • Email: dte@unr.eud
Questions for a systems developer • What am I trying to accomplish by using a computer? Are you: • Keeping track of lots of information for organization, customer, government, investor? • Making processes more efficient requiring less labor? • Facilitating decision making? • Presenting information in a more readable, attractive format? • What is the best way to accomplish your goals? • Database management system? • Spreadsheet? • Web front end? • Custom developed programs? • Combination?
Book Example: Belmont Landscapes Company provides landscape architecture services including analyzing sites, developing plans and performing construction work. Wants to have a way to keep track of the work that will be done for customers (“contracts”) and then have a way to charge those customers (“invoices”) once the work has been completed.
Why do we store data in a database? • To protect the “integrity” of the data. • Make data accurate. • Reduce data redundancy. • To make data more accessible. • Enhance flexibility of data access methods. • Improve speed of data access. • To make an application more adaptable. • Provide more flexibility in application development. • Decrease dependence on a given visualization method.
Examine the contract “spreadsheet” • Review data content. • What is the application? What is the purpose of the stored data? • Is any of the data redundant? • Why might redundant data be a problem?
Vocabulary lesson - 1 • Table: A two-dimensional database object used to store data. • Row: One “entry” of data within the table. Must have a primary key that has a different value than all other rows of data within the table • Column: A field used to store data. Must have a single data type. • Cell: An intersection of a row and column. Can only have one data type and one value.
Vocabulary lesson - 2 • Entity (when implemented it is called a “table”): A person, place, or thing about which we store data. Example is a Customer for Belmont Landscapes. • Entity instance(also called a “record” or “row”): One instance of an entity that includes all data stored about that instance. Example is “Anthony Rodriquez” for Belmont. • Attribute (also called a “field” or “column”): A characteristic of the entity about which we store data. Examples are Company, FirstName, Lastname for a Customer entity.
Process for Designing Databases • Identify all the fields needed to produce the required information • Divide each piece of data into its smallest useful part Example 1: Break up a name into first, last, initial Example 2: Break up an address into street, city, state, zip • Group related fields into tables. Start with the “strong” tables. • Use an entity-relationship diagram (ERD) to depict the design • Determine each table’s primary key • Identify how the tables are related (or if they are related) • Include a common field in related tables (foreign key) • Determine the properties of each field • Type of data: Text, date, number, etc. • Size of data • Name of data
What is a primary key? • Definition • Examples • “Natural” vs. “Surrogate”
What is a foreign key? • Definition • Example • Depiction on diagrams
What is referential integrity? • Definition: A constraint to enforce consistency between parent and child tables in a database. • “Constraint”: A limit; a set of pre-defined rules. • Conceptual example: Contract and customer. • Implementation in Access example • Create after a table has been created through the relationship diagram. • Create while the table is being created through the use of a Lookup wizard.