Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Database Intro INFO/CSE 100, Fall 2006.

Similar presentations


Presentation on theme: "1 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Database Intro INFO/CSE 100, Fall 2006."— Presentation transcript:

1 1 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Database Intro INFO/CSE 100, Fall 2006 Fluency in Information Technology http://courses.washington.edu/info100/

2 2 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Readings and References Reading »Fluency with Information Technology Chapter 14, Introduction to Database Concepts References »Access Database: Design and Programming by Steve Roman, published by O'Reilly

3 3 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Why Study Databases? Some of us want to compute, but all of us want information … Much of the archived information is in tables Databases enhance applications, e.g. Web Once you know how to create databases, you can use them to personal advantage Databases introduce interesting ideas

4 4 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Relational Databases Information is stored in tables »Tables store information about entities »Entities have characteristics called attributes »Each row in a table represents a single entity Each row is a set of attribute values Every row must be unique, identified by a key »Relationships -- associations among the data values are stored Table structure = schema Table contents = instance

5 5 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Schema for Example table: IDnumberunique number(Key) Lasttextperson’s last name Firsttextperson’s first name JobCodenumbercurrent position Hiredatefirst day on job... A Table in a Database Tables have names, attributes {fields}, entities {rows} instance schema

6 6 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Two tables in a database

7 7 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Redundancy in a database is Very Bad Not every assembly of tables is a good database Repeating data is a bad idea »Replicated data can differ in its different locations, e.g. multiple addresses can differ Inconsistent data is worse than no data Cut down on the typos and mis-keyed entries »Keep a single copy of any data Reduces memory and data processing costs if it is needed in multiple places, associate it with a key and store key rather than the data »Effort to update is high

8 8 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Relationships between tables

9 9 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Query to a database (set of tables) produces a new table “You can look it up” When looking for information, a single item might be the answer, but a table is more likely »Which employees live in Kirkland? Table of employees »Who is taking INFO/CSE 100? Table of students »Whose mile run time  4:00? Table of runners

10 10 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Select Operation Select creates a table from the rows of another table meeting a criterion Select * from Perms Where Hire < 1993

11 11 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington More Select Operation Select creates a table from the columns of another table Select Last, First From Perms This is a select from 9 dimensions to 2 dimensions

12 12 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Union Union combines two tables with same attributes Select * From Perms Union Select * From Temps

13 Join Combines rows if common field matches Select * From Perms inner join JobCodes on Perms.JobID = JobCodes.JobID

14 14 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington DB Operations These various DB Operations can create any table from a given set of tables All modern database systems are built on these relational operations The operations are not usually used directly, but are used indirectly from other languages Structured Query Language (SQL) is the language that we talk to the database in

15 15 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Database Structure A database contains one or more tables »Tables include entities with attributes »There are relationships defined between the entities in the various tables »Retrieve information from the tables using queries »Create GUI front ends (forms and reports) for users First, design the database or create the schema »What are the entities? »What are the attributes of each entity? Are they atomic? »What are the relationships between tables?

16 16 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Build a Library Database Schema What are the entities? What are the attributes of each entity? Are they atomic? What are the relationships between tables?

17 Books Publishers Authors ISBNTitle Price IDPhone Name IDPhone Name PublisherOf ∞ 1 WrittenBy ∞∞ entity-relationship diagram for Library database

18 18 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Create a new database

19 19 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Create a new table in the database

20 20 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Creating a table in Design view

21 21 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Entering Table Data

22 22 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Build another table

23 23 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Add publisher ID to books

24 24 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Create the link between the tables

25 Books Publishers Authors ISBNTitle Price IDPhone Name IDPhone Name PublisherOf ∞ 1 WrittenBy ∞∞ Hey presto, we have a database!

26 26 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Two tables with a relationship

27 27 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Create a query

28 28 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington The query produces a new (virtual) table

29 29 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Select particular columns

30 30 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Select particular rows

31 31 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington SQL behind the scenes

32 32 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Summary Databases : built on tables »Tables represent entities »Tables/Entities have attributes (fields) »Tables have a primary key (unique to that table) Related tables are “linked” using primary keys Structured Query Language (SQL) used to ask questions of database »SQL typically “called” from other programming languages »Can limit rows, columns, and join tables

33 33 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Questions A(n) ______ is a unique identifier for any row in a database table. The ______ operation takes rows from a table to create a new table.

34 34 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Questions For the following, either indicate that the field is atomic or divide the field to make the result atomic. FieldContents StudentNo47385633 Phone(206) 555-1212 NameMaria Murray ClassINFO100 : AB CitySeattle, WA 98115 DOBSeptember 26, 1983

35 35 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Questions Suppose I wanted a database to run a wine review web site. »What would some entities be? »What would some attributes be of those entities?


Download ppt "1 The Information School of the University of Washington Nov 27fit100-23-databases © 2006 University of Washington Database Intro INFO/CSE 100, Fall 2006."

Similar presentations


Ads by Google