LBSC 690: Session 7 Relational Databases

Slides:



Advertisements
Similar presentations
Relational Databases Week 9 INFM 603.
Advertisements

Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Mani-CS34311 CS3431 – Database Systems I Introduction Instructor: Murali Mani
LBSC 690 Session #7 Structured Information: Databases Jimmy Lin The iSchool University of Maryland Wednesday, October 15, 2008 This work is licensed under.
From Class Diagrams to Databases. So far we have considered “objects” Objects have attributes Objects have operations Attributes are the things you record.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Database Management: Getting Data Together Chapter 14.
Entity-Relationship Model and Diagrams (continued)
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.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 1 Database Systems I Introduction.
Databases Week 7 LBSC 690 Information Technology.
Week 6 LBSC 690 Information Technology
Databases Week 6 LBSC 690 Information Technology.
© Anselm SpoerriInfo + Web Tech Course Information Technologies Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University
1 The Big Picture of Databases We are particularly interested in relational databases Data is stored in tables.
Relational Databases Week 7 LBSC 690 Information Technology.
Compe 301 ER - Model. Today DBMS Overview Data Modeling Going from conceptual requirements of a application to a concrete data model E/R Model.
Distributed Databases
IST Databases and DBMSs Todd S. Bacastow January 2005.
1 Relational Databases. 2 Find Databases here… 3 And here…
Relational Databases Week 13 LBSC 671 Creating Information Infrastructures.
Relational Databases Week 9 INFM 603. Agenda Relational database design Microsoft Access MySQL Main Class Project Proposal Presentation.
1 DATABASE TECHNOLOGIES BUS Abdou Illia, Fall 2007 (Week 3, Tuesday 9/4/2007)
Introduction. 
1 Introduction to Database Systems. 2 Database and Database System / A database is a shared collection of logically related data designed to meet the.
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Wednesday, March 5, 2014 Session 6: Relational.
Databases Session 5 LIS 7008 Information Technologies LSU/SLIS.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Page 1 Topic 4 Relational Databases CPS510 Database Systems Abdolreza Abhari School of Computer Science Ryerson University.
CSC 240 (Blum)1 Introduction to Database. CSC 240 (Blum)2 Data versus Information When people distinguish between data and information, –Data is simply.
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Databases Week 5 LBSC 690 Information Technology.
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
1 Chapter 1 Introduction. 2 Introduction n Definition A database management system (DBMS) is a general-purpose software system that facilitates the process.
Databases. Not All Tables Are Created Equal Spreadsheets use tables to store data and formulas associated with that data The “meaning” of data is implicit.
MS Access 2007 Management Information Systems 1. Overview 2  What is MS Access?  Access Terminology  Access Window  Database Window  Create New Database.
Relational Databases Week 11 LBSC 671 Creating Information Infrastructures.
Introduction to Database Systems1. 2 Basic Definitions Mini-world Some part of the real world about which data is stored in a database. Data Known facts.
1 CS3431 – Database Systems I Introduction Instructor: Mohamed Eltabakh
U:/msu/course/cse/103 Day 18, Slide 1 CSE 103 Day 18 If you are not enrolled in CSE 103, please save and log out by 10:10.
Introduction.  Administration  Simple DBMS  CMPT 454 Topics John Edgar2.
Fall CSE330/CIS550: Introduction to Database Management Systems Prof. Susan Davidson Office: 278 Moore Office hours: TTh
ER & Relational: Digging Deeper R &G - Chapters 2 & 3.
1 Geog 357: Data models and DBMS. Geographic Decision Making.
1 CS462- Database Systems Sang H. Son
Data The fact and figures that can be recorded in system and that have some special meaning assigned to it. Eg- Data of a customer like name, telephone.
ASET 1 Amity School of Engineering & Technology B. Tech. (CSE/IT), III Semester Database Management Systems Jitendra Rajpurohit.
Advanced Database CS-426 Week 6 – Transaction. Transactions and Recovery Transactions A transaction is an action, or a series of actions, carried out.
CS3431: C-Term CS3431 – Database Systems I Introduction Instructor: Mohamed Eltabakh
Data Modeling Session 12 INST 301 Introduction to Information Science.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Database Management Systems Chapter 1.
Relational Databases (Part 2) Session 14 INST 301 Introduction to Information Science.
1 CENG 351 CENG 351 Introduction to Data Management and File Structures Department of Computer Engineering METU.
CSCI-235 Micro-Computers in Science Databases. Database Concepts Data is any unorganized text, graphics, sounds, or videos A database is a collection.
CHAPTER 1: INTRODUCTION Purpose of Database Systems View of Data Data Models Data Definition Language Data Manipulation Language Storage Management Database.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
Chapter 2 The Big Picture. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 2-2 Databases We are particularly interested in relational databases.
Databases and DBMSs Todd S. Bacastow January
Databases We are particularly interested in relational databases
Chapter 1: Introduction
Chapter 1: Introduction
Translation of ER-diagram into Relational Schema
From ER to Relational Model
Microsoft Access and SQL
Data Models in DBMS A model is a representation of reality, 'real world' objects and events, associations. Data Model can be defined as an integrated collection.
Week 6 LBSC 690 Information Technology
Is the WWW a DBMS? = Fairly sophisticated search available
Presentation transcript:

LBSC 690: Session 7 Relational Databases Jimmy Lin College of Information Studies University of Maryland Monday, October 22, 2007 Some content borrowed from slides by Michael Franklin, UC Berkeley

Databases Then…

Databases Now…

And here…

And here…

What is a database system? a large, integrated collection of data Models something about the real world Entities (e.g., teams, games) Relationships (e.g., the Red Sox won the World Series) More recently, also includes active components, often called “business logic” (e.g., the playoff system) A Database Management System (DBMS) is a software system designed to store, manage, and facilitate access to databases Today’s focus on relational databases

= Is the WWW a DBMS? Fairly sophisticated search available Crawler indexes pages on the Web Keyword-based search for pages But, currently Data is mostly unstructured and untyped Can’t modify the data Can’t get summaries, complex combinations of data Few guarantees provided for freshness of data, consistency across data items, fault tolerance, … The picture is changing New standards, e.g., XML, Semantic Web, etc., can provide richer models of data

Discussion Point What is the difference between searching and querying?

Database Basics What is a database? Collection of data, organized to support access Models some aspects of reality Components of a relational database: Field = an “atomic” unit of data Record = a collection of related fields Table = a collection of related records Each record is one row in the table Each field is one column in the table Primary Key = the field that uniquely identifies a record Database = a collection of tables

A Simple Example Field Name Table Name DOB SSN John Doe 04/15/1970 153-78-9082 Jane Smith 08/31/1985 768-91-2376 Mary Adams 11/05/1972 891-13-3057 Record Field Primary Key

Why “Relational”? Databases model some aspects of reality A relational database views the world in terms of entities and relations between them: Tables represent “relations” Named fields represent “attributes” Each row in the table is called a “tuple”

The Registrar Example What do we need to know (i.e., model)? Something about the students (e.g., first name, last name, email, department) Something about the courses (e.g., course ID, description, enrolled students, grades) Which students are in which courses

A First Try Discussion: Why is this a bad idea? Put everything in a big table… Discussion: Why is this a bad idea?

Goals of “Normalization” Save space Save each fact only once More rapid updates Every fact only needs to be updated once More rapid search Finding something once is good enough Avoid inconsistency Changing data once changes it everywhere

Another Try... Student Table Department Table Course Table Enrollment Table

Approaches to Normalization For simple problems (like the homework): Start with “binary relationships”: pairs of fields that are related Group together wherever possible Add keys where necessary For more complicated problems: Entity relationship modeling (LBSC 670)

Some Lingo “Primary Key” uniquely identifies a record e.g., student ID in the student table “Foreign Key” is primary key in the other table It need not be unique in this table

The Data Model Student Table Department Table Course Table Enrollment Table

Join Student Table Department Table “Joined” Table

Project SELECT Student ID, Department

Restrict WHERE Department ID = “HIST”

Relational Operations Joining tables: JOIN Choosing columns: SELECT Based on their label Choosing rows: WHERE Based on their contents These can be specified together department ID = “HIST” SELECT Student ID, Dept WHERE Dept = “History”

Database Integrity Registrar database must be internally consistent All enrolled students must have an entry in the student table All courses must have a name … What happens: When a student withdraws from the university? When a course is taken off the books?

Integrity Constraints Conditions that must be true of the database at any time Specified when the database is designed Checked when the database is modified RDBMS ensures that integrity constraints are always kept So that database contents remain faithful to the real world Helps avoid data entry errors Where do integrity constraints come from?

Discussion Point How is a relational database different from a spreadsheet?

Database Architectures two vs. three-tiered architectures Application Application Client network network Server “Middleware” Database System

Heavy-duty Demands Typical database applications: Characteristics: Banking (e.g., saving/checking accounts) Trading (e.g., stocks) Airline reservations … Characteristics: Lots of data Lots of concurrent access Must have fast access “Mission critical”

Reliability Thought experiment: the power goes out when… You’re editing a file You’re in the middle of opening a file You’re in the middle of saving a file How do you build systems under such circumstances? Very carefully! What happens? 4

Concurrency Thought experiment: You and your project partner are editing the same file… Scenario 1: you both save it at the same time Scenario 2: you save first, but before it’s done saving, your partner saves How do you build systems under such circumstances? Very carefully Whose changes survive? A) Yours B) Partner’s C) neither D) both E) ??? 4

Concurrency Example Possible actions on a checking account Scenario: Deposit check (read balance, write new balance) Cash check (read balance, write new balance) Scenario: Current balance: $500 You try to deposit a $50 check and someone tries to cash a $100 check at the same time Possible sequences: (what happens in each case?) Deposit: read balance Deposit: write balance Cash: read balance Cash: write balance Deposit: read balance Cash: read balance Cash: write balance Deposit: write balance Deposit: read balance Cash: read balance Deposit: write balance Cash: write balance

Database Transactions Transaction = sequence of database actions grouped together e.g., transfer $500 from checking to savings ACID properties: Atomicity: all-or-nothing Consistency: each transaction must take the DB between consistent states. Isolation: concurrent transactions must appear to run in isolation Durability: results of transactions must survive even if systems crash

Making Transactions the log Idea: keep a log (history) of all actions carried out while executing transactions Before a change is made to the database, the corresponding log entry is forced to a safe location Recovering from a crash: Effects of partially executed transactions are undone Effects of committed transactions are redone Trickier than it sounds! the log

Entity-Relationship Diagrams A database models some aspect of reality… ER diagrams are a way for graphically visualizing this Entities are captured in boxes Relationships are captured using arrows

The Data Model Student Table Department Table Course Table Enrollment Table

Registrar ER Diagram Student Student ID First name Last name Department E-mail … Enrollment Student Course Grade … has associated with has Course Course ID Course Name … Department Department ID Department Name …

Example ER Diagram

Types of Relationships Many-to-Many 1-to-Many 1-to-1

More Complex ER Diagram cadastral: a public record, survey, or map of the value, extent, and ownership of land as a basis of taxation. Source: US Dept. Interior Bureau of Land Management, Federal Geographic Data Committee Cadastral Subcommittee http://www.fairview-industries.com/standardmodule/cad-erd.htm

Steps in Database Design Requirements Analysis: what must database do? Conceptual Design: high level description (often done with ER model) Logical Design: translate ER into DBMS data model Schema Refinement: consistency, normalization Physical Design: indexes, disk layout Security Design: who accesses what, and how

RideFinder Exercise Design a database to match drivers with passengers (e.g., for road trips): Drivers post available seats; they want to know about interested passengers Passengers call up looking for rides: they want to know about available rides (they don’t get to post “rides wanted” ads) These things happen in no particular order

Exercise Goals Identify the tables you will need First decide what data you will save: What questions will be asked? Then decide how to group/split it into tables Design queries (using join, project, and restrict) What happens when a passenger comes looking for a ride? What happens when a driver comes to find out who his passengers are?