Databases Session 5 LIS 7008 Information Technologies LSU/SLIS.

Slides:



Advertisements
Similar presentations
Relational Databases Week 9 INFM 603.
Advertisements

LBSC 690 Session #7 Structured Information: Databases Jimmy Lin The iSchool University of Maryland Wednesday, October 15, 2008 This work is licensed under.
Microsoft Access 2003 Introduction To Microsoft Access 2003.
Database Management: Getting Data Together Chapter 14.
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.
Databases Week 7 LBSC 690 Information Technology.
Week 6 LBSC 690 Information Technology
Databases Week 6 LBSC 690 Information Technology.
LBSC 690: Session 7 Relational Databases
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 1 1 Microsoft Access 2003 Tutorial 1 – Introduction To Microsoft Access 2003.
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Relational Databases Week 7 LBSC 690 Information Technology.
Management Information Systems MS Access 2003 By: Mr. Imdadullah Lecturer, Department of M.I.S. College of Business Administration, KSU.
Access Tutorial 10 Automating Tasks with Macros
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
1 Relational Databases. 2 Find Databases here… 3 And here…
Relational Databases Week 13 LBSC 671 Creating Information Infrastructures.
Database Applications – Microsoft Access Lesson 2 Modifying a Table and Creating a Form 45 slides in presentation Accessibility check 9/14.
Relational Databases Week 9 INFM 603. Agenda Relational database design Microsoft Access MySQL Main Class Project Proposal Presentation.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 1 1. Chapter 2: Relational Databases and Multi-Table Queries Exploring Microsoft Office.
FIRST COURSE Access Tutorial 1 Creating a Database.
Copyright © 2003 by Prentice Hall Module 4 Database Management Systems 1.What is a database? Data hierarchy and data organization Field, record, file,
CPSC 203 Introduction to Computers T59 & T64 By Jie (Jeff) Gao.
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 13 Database Management Systems: Getting Data Together.
XP New Perspectives on Microsoft Access 2002 Tutorial 51 Microsoft Access 2002 Tutorial 5 – Enhancing a Table’s Design, and Creating Advanced Queries and.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
DAY 14: ACCESS CHAPTER 1 Tazin Afrin October 03,
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Wednesday, March 5, 2014 Session 6: Relational.
Microsoft Access Get a green book. Page AC 2 Define Access Define database.
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
Most Difficult and Confusing Topics Pre-Class Face-to-Face Meeting LIS 7008 Information Technologies LSU/SLIS.
Lesson 2.  To help ensure accurate data, rules that check entries against specified values can be applied to a field. A validation rule is applied to.
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
McGraw-Hill/Irwin © 2008 The McGraw-Hill Companies, All Rights Reserved Plug-In T8: Decision Making Using Access 2007 Business Driven Technology.
XP 1 Microsoft Access 2003 Introduction To Microsoft Access 2003.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
Databases Week 5 LBSC 690 Information Technology.
Chapter 17 Creating a Database.
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.
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 8 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 8 Creating.
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.
Database collection of related information stored in an organized form Database program software tool for storage & retrieval of that information.
McGraw-Hill/Irwin ©2005 The McGraw-Hill Companies, All rights reserved ©2005 The McGraw-Hill Companies, All rights reserved McGraw-Hill/Irwin.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. Adding a new field 1Right click the table name and select design view 2Type the field information at the end.
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.
Access Chapter 1: Intro to Access Objectives Navigate among objects in Access database Difference between working in storage and memory Good database file.
Lesson 4.  After a table has been created, you may need to modify it. You can make many changes to a table—or other database object—using its property.
Relational Databases Week 7 INFM 603.
CPSC 203 Introduction to Computers T97 By Jie (Jeff) Gao.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
Microsoft Office 2013 Try It! Chapter 4 Storing Data in Access.
ASET 1 Amity School of Engineering & Technology B. Tech. (CSE/IT), III Semester Database Management Systems Jitendra Rajpurohit.
Access Module Implementing a Database with Microsoft Access A Great Module on Your CD.
Access Queries and Forms. Adding a New Field  To insert a field after you have saved your table, open Access, and open the table  It is easier to add.
Data Modeling Session 12 INST 301 Introduction to Information Science.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Relational Databases (Part 2) Session 14 INST 301 Introduction to Information Science.
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
N5 Databases Notes Information Systems Design & Development: Structures and links.
GO! with Microsoft Office 2016
Practical Office 2007 Chapter 10
GO! with Microsoft Access 2016
Microsoft Access and SQL
Week 6 LBSC 690 Information Technology
Class 5 LBSC 690 Information Technology
Presentation transcript:

Databases Session 5 LIS 7008 Information Technologies LSU/SLIS

Quiz Avg =88

If you have skipped: Hands-on exercises of any session –Work on it, or ask classmates, or TA/me Any homework –Work on it, or ask classmates, or TA/me The Quiz –Work on it on your own Discussions of any earlier session –Contribute to your class participation credit!

Agenda Relational database design –Relational DB, object-oriented DB, network DB, hierarchical DB, etc. Microsoft Access –DBMS for creating relational DB –Graphical programming interface for skipping SQL –Oracle, Sybase, MySQL, Dbase, etc.

Databases Database (DB) –A DB is a collection of data, organized to support access –DB models some aspects of reality (such as university enrollment), not everything in the world. –DB has data itself, and the structure of data (for organizing data). Data Base Management System (DBMS) –Software to create and access databases –DBMS is at the level of programming language. Computer scientists design DBMS. MS-Access is a DBMS. –LSU Computer Science Dept. offers CSC 4402 DBMS. Relational Algebra –Special-purpose programming language to create DBMS

Structured Information in DB Database A collection of tables Table A collection of related records –Each record is one row in the table –Each field is one column in the table. Record A collection of related fields –A row represents a record. Field An “atomic” unit of data –number, string, true/false, … –A column represents a field; models some aspect of the reality (e.g., attribute of an entity) Primary KeyThe field that uniquely identifies a record –Values of a primary key must be unique

A Simple Example primary key

Registrar Example: Enrollment Query: which students are in which courses? –Relationship b/t students and courses is assigned What do we need to know about the students? –What do you want to know about “students”? –Attributes: first name, last name, , department –What about professors? What do we need to know about the courses? –What do you want to know about “courses”? –Attributes: course ID, description, enrolled students, grades

A “Flat File” Solution Using MS-Excel Discussion Topic Why is this a bad approach?

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

Relational Algebra Terminology Tables represent “relations” –“course ID” and “course description” are related. –“Name” and “ address” are related. Named fields represent “attributes” –Attributes of Course: course ID, description, … –Attributes of Student: first name, last name, … Each row in the table is also called a “tuple” –The order of the rows is not important Queries specify desired conditions –The DBMS then finds data that satisfies them

A Normalized Relational Database Student Table Department TableCourse Table Enrollment Table A foreign key of a table refers to the primary key of an other table. The Enrollment Table has two foreign keys.

Approaches to Normalization For simple problems (like the homework) –Start with “binary relationships” Pairs of fields that are related, e.g., Student ID, Last Name –Group together wherever possible –Add keys where necessary For more complicated problems: –Need to do Entity Relationship (E-R) modeling before designing tables –If interested, read Entity-Relationship Model at

Example of Join Student TableDepartment Table “Joined” Table

Problems with Join Data modeling for “join” is complex “Join” is expensive to compute –Both in time and storage space But it is “joins” that make databases relational –Projection and restriction are also used in flat files

Some Lingo “Primary Key” uniquely identifies a record –e.g. student ID in the Student table “Compound” primary key –Synthesize a primary key with a combination of fields –e.g., Student ID + Course ID in the Enrollment table “Foreign Key” in this table is a primary key in the other table –Note: it need not be unique in this table E.g., Department ID in the Student table is a foreign key; it is a primary key in the Department table. –Foreign keys are used to “join” other tables

Project New Table SELECT Student ID, Department

Restrict New Table SELECT * FROM New Table WHERE Department ID = “HIST”

Entity-Relationship (E-R) Diagrams Graphical visualization of the data model –a visual representation of an entity-relationship model. Entities are captured in boxes Relationships are captured using arrows

Registrar E-R Diagram Enrollment Student Course Grade … Student Student ID First name Last name Department … Course Course ID Course Name … Department Department ID Department Name … has associated with offered by

Types of Relationships 1-to-1 1:1 1-to-Many 1:M Many-to-Many M:N

A More Complex E-R 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

Databases in the Real World Some typical database applications: –Banking (e.g., saving/checking accounts) –Trading (e.g., stocks) –Airline reservations –What if you screwed up your org’s DB? Characteristics: –Lots of data –Lots of concurrent access –Must have fast access –“Mission critical”

Database Integrity Registrar database must be internally consistent –Enrolled students must have an entry in student table –Courses must have a name What happens: –When a student withdraws from the university? What tables are affected? –When a course is taken off the books?

Integrity Constraints Conditions that must always be true –Specified when the database is designed –Checked when the database is modified R-DBMS ensures integrity constraints are respected –So database contents remain faithful to real world –Helps avoid data entry errors

Referential Integrity Foreign key values must exist in other table –If not, those records cannot be joined Can be enforced when data is added –Associate a primary key with each foreign key Helps avoid erroneous data –Only need to ensure data quality for primary keys

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 Whose changes survive? A) Yours B) Partner’s C) neither D) both E) ???

Concurrency Example Possible actions on a checking account –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 grouped database actions –e.g., transfer $500 from checking to savings “ACID” properties –Atomicity All-or-nothing: either all related transactions made or nothing made –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 –Transactions are logged

Making Transactions 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 the log

RideFinder Database Exercise Suppose you run a small business on campus –say, Student Ride Booking Company Design a database to match passengers with available rides over the Spring Break –Drivers phone in available seats They want to know about interested passengers –Passengers call up looking for rides They want to know about available rides –These things happen in no particular order –Your business is to assign rides to passengers This exercise may take minutes.

Exercise Goals Identify the tables you will need –First decide what data you will save What questions will be asked by passengers/drivers? –These will be the queries –Then decide how to group/split it into tables Start with binary relations if that helps Design the queries –Using join, project and restrict Add primary and foreign keys where needed

Exercise Logistics Best work in groups of 3 or 4 students –Although you can work by yourself Brainstorm data requirements for 5 minutes –Do passengers care about the price of a ride? –Do drivers care how much luggage there is? Develop tables and queries for 15 minutes –Don’t get hung up on one thing too long Compare your answers with another group –Should take about 5 minutes

RideFinder Database See my Sample Database (RideFinder): on Syllabus page (under Notes)

How to Read a Database File Using MS-Access To view the structure of a table: right-click a table, view "design view". To view the data of a table: first view "design view", then click View  Datasheet view. To view a query: right-click the query, view "design view". To run a query: double click the query.

Database “Programming” Natural language queries –Goal is ease of use e.g., Show me the last names of students in SLIS vocal queries –Ambiguity sometimes results in errors Structured Query Language (SQL) –Consistent, unambiguous interface to any DBMS –Simple command structure: e.g., SELECT LastName FROM Students WHERE Dept=SLIS –Useful standard for inter-process communications Visual programming (e.g., Microsoft Access) –Unambiguous, and easier to learn than SQL

SQL: The SELECT Command Project chooses columns –Based on their label Restrict chooses rows –Based on their contents e.g. department ID = “HIST” These can be specified together –SELECT Student ID, Dept FROM New Table WHERE Department ID = “HIST”

SQL: Restrict Operators Each SELECT contains a single WHERE Numeric comparison, =, <>, … e.g., grade<80; price<20 Boolean operations –e.g., Name = “John” AND DeptID <> “HIST” –<> means not equal to

Using Microsoft Access Procedure Create a DB –Click Blank Database –Define file name (e.g., mydb.accdb) –Click Create Create Tables –Click Create  Table –In the Ribbon, get Design View of the table –Define table name, save –Name your fields, specify field properties –Define Primary Key (a field of a table)

MS-Access Create Records and Relationships Create Records –Get a table’s Datasheet View –Input data for each record –Click Save icon when done Create/add Relationships –Click Database Tool tab –Click Relationships –To create/add a relationship between two tables: put cursor on one field of a table, click and drag it onto a field of another table

MS-Access Create Queries Click Create  Query Design Select the tables involved Define fields and criteria Define query name, save Double click the query to run

MS-Access 2010 Tutorials My tutorial: – SampleDB/Access2010/Access2010.htmlhttp:// SampleDB/Access2010/Access2010.html Other people’s tutorials: –See syllabus page (under Useful Resources)

MS-Access 2007 Tutorials My tutorial: – 4/SampleDB/Access2007/Access2007.htmlhttp:// 4/SampleDB/Access2007/Access2007.html Other people’s tutorials: –See the syllabus page (under Useful Resources) – – –

MS-Access Tutorials My tutorial: 4/SampleDB/Access2000/Access2000.html 4/SampleDB/Access2000/Access2000.html Other tutorials: – s/tutorials/access2000/Access2000Tutorial.htmlhttp:// s/tutorials/access2000/Access2000Tutorial.html – s_tutorial_2000.htmlhttps:// s_tutorial_2000.html

Using Microsoft Access Create a database called rides.mdb –File  New  Blank Database Specify the fields (columns) –“Create a Table in Design View” Fill in the records (rows) – Double-click on the icon for the table

MS-Access Creating Fields Enter field name –Must be unique, but only within the same table Select field type from a menu –Use date/time for times –Use text for phone numbers Designate primary key (right mouse button) Save the table –That’s when you get to assign a table name

MS-Access Entering Data Open the table –Double-click on the icon Enter new data in the bottom row –A new (blank) bottom row will appear Close the table –No need to “save” – data is stored automatically

MS-Access Building Queries Copy ride.mdb to your computer “Create Query in Design View” –In “Queries” Choose two tables Pick each field you need using the menus –Unclick “show” to not project –Enter a criterion to “restrict” Save, exit, and reselect to run the query

Fun Facts about Queries “Joins” are automatic if field names are same –Otherwise, drag a line between the fields Sort order is easy to specify –Use the menu Queries form the basis for reports –Reports give good control over layout –Use the report wizard - the formats are complex

Other Things to Know Data input forms manage input better than raw tables –Invalid data can be identified when input –Graphics can be incorporated

Key Ideas Relational Databases are a good choice when you have: –Lots of data –And a problem that contains inherent relationships Design before you implement –This is just another type of programming –The mythical person-month applies! Join is the most important concept –Project and restrict just remove undesired stuff

Discussion Point: Mythical Person-Month Why is software development different from manufacturing car? If it would take 1 person 3 months, why does it take 4 people 6 months? Reminder: read the Mythical Person-Month paper posted on the syllabus page

Trading People and Months is Hard Sequential constraints –in the procedure of software development Communication –between team members Training –if new members join the team

Estimating Completion Time Rules of thumb –1/3 specification –1/6 coding –1/2 test planning, testing, and fixing! –This applies to your course project! Add time for coding to learn as you go, but don’t take time away from the other parts! –Reread the section on “gutless estimating” if you are tempted

HW5: “type mismatch in query" Problem1: Every time I run a query it says "Type mismatch in query." Problem 2 : My database cannot enforce referential integrity. Solution: In order to remain data integrity, databases declares the types of data. For instance, if the StudentID in Table1 is a "string" type, and the StudentID in Table2 is a "number" type, when you want to relate the two fields, the DBMS reports a "type mismatch" error. So to correct such a mistake, you need to go back to the structures of the both tables, and check the types of the two fields to make sure their types match.

Project Find a client Student Trip Travel Insurance – travel-insurancehttps://sites01.lsu.edu/wp/riskmgt/student-trip- travel-insurance –Please fill out the online form before going to meet with your client Project management issues –Read paper on Man-mythical theory Copyright and information ethics issue