Relational Database Concepts. Let’s start with a simple example of a database application Assume that you want to keep track of your clients’ names, addresses,

Slides:



Advertisements
Similar presentations
CHAPTER OBJECTIVE: NORMALIZATION THE SNOWFLAKE SCHEMA.
Advertisements

BUSINESS DRIVEN TECHNOLOGY Plug-In T4 Designing Database Applications.
MICROSOFT OFFICE ACCESS 2007.
8 June Single table database in normal form Fields and records Normal form 1.Header in the first line 2.Same content for every field 3.Each record.
Exploring Microsoft Access 2003 Chapter 6 Many-to-Many Relationships: A More Complex System.
ISP 121 Access Normalization and Relationships. Normalization Say we’re operating a pet day-care and we need to keep information on our pets/customers.
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
Introduction to Databases CIS 5.2. Where would you find info about yourself stored in a computer? College Physician’s office Library Grocery Store Dentist’s.
1 The Information School of the University of Washington Nov 29fit forms © 2006 University of Washington More Forms INFO/CSE 100, Fall 2006 Fluency.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Management Information Systems MS Access 2003 By: Mr. Imdadullah Lecturer, Department of M.I.S. College of Business Administration, KSU.
Relational Databases What is a relational database? What would we use one for? What do they look like? How can we describe them? How can you create one?
Case study Lisa’s Bookstore IST210.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Lesson 32: Designing a Relational Database. 2 Lesson Objectives After studying this lesson, you will be able to:  Identify and apply principles for good.
Database Relationships Objective 5.01 Understand database tables used in business.
Introduction to Databases
Chapter 7 Logical Database Design
Entity Relationship Diagram Farrokh Alemi Ph.D. Francesco Loaiza, Ph.D. J.D. Vikas Arya.
Database Relationships Objective 5.01 Understand database tables used in business.
1 Microsoft Access 2002 Tutorial 3 – Querying a Database.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
CS&E 1111 AcInnerJoins Inner Joins Objectives: Creating Queries with data from Multiple Tables Joining two tables using an Inner Join Referential Data.
24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
Concepts of Database Management, Fifth Edition Chapter 4: The Relational Model 3: Advanced Topics.
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Data Modelling – ERD Entity Relationship Diagram’s Entity Relationship Diagrams and how to create them. 1.
Relational databases and third normal form As always click on speaker notes under view when executing to get more information!
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
DOMAIN MODEL— PART 2: ATTRIBUTES SYS466. Looking For Potential Classes “Know the business”. Ask Questions Identify business concepts; filter nouns (person,
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
Database Normalization Lynne Weldon July 17, 2000.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 9 1 Microsoft Office Access 2003 Tutorial 9 – Using Action Queries, and Defining Table Relationships.
DAY 12: DATABASE CONCEPT Tazin Afrin September 26,
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
CS 101 – Access notes Databases (Microsoft Access) 4 parts of a database database design –Try to understand the ideas behind database design, not just.
Introduction to Databases Trisha Cummings. What is a database? A database is a tool for collecting and organizing information. Databases can store information.
MS Access 2007 Management Information Systems 1. Overview 2  What is MS Access?  Access Terminology  Access Window  Database Window  Create New Database.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
Microsoft Access Intro Class 6 Relationships.
M1G Introduction to Database Development 5. Doing more with queries.
CSC 240 (Blum)1 Introduction to Data Entry, Queries and Reports.
Fanny Widadie, S.P, M.Agr 1 Database Management Systems.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-1 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining.
Exploring Microsoft Access Chapter 6 Many-to-Many Relationships: A More Complex System.
Introduction to Database using Microsoft Access 2013 Part 7 November 19, 2014.
1 CSE 2337 Introduction to Data Management Access Book – Ch 1.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. Adding a new field 1Right click the table name and select design view 2Type the field information at the end.
Pasewark & Pasewark 1 Access Lesson 3 Creating Queries Microsoft Office 2007: Introductory.
1 The Information School of the University of Washington Dec 1fit advdatabases © 2006 University of Washington Advanced Database Concepts INFO/CSE.
IBS 520 Introduction to Internet Technology Database Fundamentals Week 4.
CHAPTER 1 – INTRODUCTION TO ACCESS Aliya Farheen March 5, 2014.
Lesson 2: Designing a Database and Creating Tables.
CSC 240 (Blum)1 Introduction to Access CSC 240 (Blum)2 Click on the Access desktop icon or go to Start/All Programs/Microsoft Office/Microsoft Office.
BSA206 Database Management Systems Lecture 2: Introduction to Oracle / Overview of Database Concepts.
MIS2502: Data Analytics Relational Data Modeling
Relational Database in Access Student System As always please use speaker notes!
MIS2502: Data Analytics Relational Data Modeling David Schuff
Database Relationships Objective 5.01 Understand database tables used in business.
Database (Microsoft Access). Database A database is an organized collection of related data about a specific topic or purpose. Examples of databases include:
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 2 Objectives: Understanding and Creating Table.
Database Relationships
Database Relationships
INFO/CSE 100, Spring 2005 Fluency in Information Technology
Relational Queries (query 12) Display vendor contact info (contact person and phone number) for inventory products (relationship query) Query: Inventory.
INFO/CSE 100, Spring 2006 Fluency in Information Technology
Database Relationships
Advanced Database Concepts: Reports & Views
Presentation transcript:

Relational Database Concepts

Let’s start with a simple example of a database application Assume that you want to keep track of your clients’ names, addresses, and phone numbers.

Client information to store and retrieve Name Address Phone Number

A typical design and sample table entries might be: Name AddressPhone Janice Chen236 Boylston Ave. Boston, MA Al BrownBradford St., Provincetown 28, MA Janice Chen36 Commonwealth Ave., Brookline, MA

But if we wanted to sort the records in alphabetical order by name in the usual way, there would be a problem because the last name is buried in the Name field. Solution: Split the Name field into 2 atomic fields, Last Name and First Name.

Similarly, we may want to query the database for all clients from MA, or all clients from Brookline, or group clients by ZIP code for mass mailings. To do this, we need to break the address into several smaller atomic fields as well. Our table then looks as follows:

Last NameFirst NameStreetCityStateZipPhone ChenJanice236 Boylston Ave.BostonMA BrownAl28 Bradford St.ProvincetownMA ChenJanice36 Commonwealth Ave. BrooklineMA

Primary key How can we identify a record in this table uniquely? Notice that the last name is not sufficient; nor is the combination of last name and first name. Perhaps the combination of all the name and address fields is sufficient.

A primary key in a table is a field or combination of fields that uniquely distinguishes any record from all other records. Every table in a relational database must have a primary key.

So in this example, perhaps we could specify the combination of all the name and address fields as the primary key (or perhaps the combination of the 2 name fields along with the phone number).

A single field is generally preferable as a primary key, so one choice we have available for our database is to add an additional field – Social Security Number. These are guaranteed to identify individuals uniquely. An alternative is to generate our own numbering system for clients, say C001, C002, etc.

Now let’s consider a slightly more involved example Assume that you have a small company selling books and you want to keep track of your customers’ orders. To keep things simple, let’s assume that among the data we intend to keep track of for each order is the following:

Data to store and retrieve about customer orders Customer Name Customer Address Book Title Quantity Ordered Date Shipped Purchase Price etc.

As before, we’ll probably want to break the name and address fields down further, but here we’ll take those details for granted and emphasize some additional considerations.

First, let’s imagine placing all the data in a single table. Since a customer can order books at different times (or even multiple books in a single order), we can end up with multiple records containing the identical name and address information for a customer.

This one table will thus contain redundant information, which can lead to more date entry errors or updating errors if some of the customer data changes. And of course it wastes space.

The solution is to have multiple tables. In particular, we should have a separate Customers table that holds only things like the name and address of customers. We’ll also have an Orders table.

Foreign keys One of the fields in the Orders table will identify which customer the order is for. Instead of using the entire name and address of the customer in the Orders table, we’ll use a simple customer id number to identify the customer.

This customer id number will be used as a primary key in the Customers table, and it will also be used as a foreign key in the Orders table, to identify which customer placed the order. A foreign key is just a kind of pointer to information in a related table.

Many-to-one relationships Since each order is placed by exactly one customer, but each customer may place many orders, there is a many-to- one relationship between orders and customers. Many-to-one relationships always require the use of a foreign key in the “many” table (Orders in this case).

We can expand on this example by considering how we might keep track of our book inventory. In particular, let’s also have a Books table that stores all the information about the books we sell, including title, author, publisher, etc.

Many-to-many relationships One order can be for more than one book, and any book can appear in multiple orders. Thus there is a many-to-many relationship between books and orders.

The way to handle the many-to-many relationship between books and orders is to have an additional table besides the Books and Orders tables. We’ll call this table Order Details.

The Order Details table may contain multiple entries for any particular order and multiple entries for any particular book. It contains foreign keys pointing to the Orders table and to the Books table.

Here is how the Relationships Window in Access displays this information, by listing the names of all the fields in all 4 tables and showing which fields (foreign keys) correspond to which other fields(primary keys) in other tables. Primary keys are indicated in bold. (ISBN number is a standard unique identifier for books.)

Referential Integrity The point of this example has been to show how a useful database may contain multiple tables. But when there are related tables, care must be taken to insure that the relationships between the tables are respected.

Consider what might happen if a customer is deleted from the Customers table. If there is an entry in the Orders table for this customer, it would now contain a meaningless customer id.

There are 2 possible solutions to this problem: Do not allow a customer to be deleted from the Customers table if there are corresponding orders in the Orders table When deleting an entry from the Customers table, delete all corresponding orders for that customer (called cascaded deletion).

Queries and Joins Retrieving information from the database is done using queries. Consider a query of the form: Find the names and addresses of all customers who have ordered books by a particular author.

This involves: looking in the Books table to find all books by that author, then looking in the Order Details table to see which orders were for those books, then looking in the Orders table to see which customers placed those orders, and finally, looking in the Customers table to get the names and addresses of these customers.

On the other hand, if we had kept all the information in just 1 big table, we could have just pulled the information out of that table. The join of 2 or more related tables is conceptually just the same as one large table combining the information from the smaller tables.

A query involving multiple tables is sometimes said to be a query on the join of those tables. The actual join itself need not be determined; it is just a conceptual entity. Just think of the process in the way we described it earlier: looking up information in one table, then in another table, etc.