Database Management Systems. Rebecca Koskela DataONE University of New Mexico

Similar documents
Physical Design. Meeting the needs of the users is the gold standard against which we measure our success in creating a database.

Relational Database Basics Review

Tutorial on Relational Database Design

How To Create A Table In Sql (Ahem)

DBMS / Business Intelligence, SQL Server

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

The Relational Model. Why Study the Relational Model?

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

database abstraction layer database abstraction layers in PHP Lukas Smith BackendMedia

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

EECS 647: Introduction to Database Systems

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. Introduction to Databases. Why databases? Why not use XML?

Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

Lecture 6. SQL, Logical DB Design

COMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries

Foundations of Information Management

A Brief Introduction to MySQL

Oracle Database 10g Express

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7

What is a database? COSC 304 Introduction to Database Systems. Database Introduction. Example Problem. Databases in the Real-World

SQL Server An Overview

3. Relational Model and Relational Algebra

Microsoft Access 3: Understanding and Creating Queries


types, but key declarations and constraints Similar CREATE X commands for other schema ëdrop X name" deletes the created element of beer VARCHARè20è,

Databases 2011 The Relational Model and SQL

Database Systems. Lecture 1: Introduction

- Suresh Khanal. Microsoft Excel Short Questions and Answers 1

MySQL for Beginners Ed 3

Information Technology NVEQ Level 2 Class X IT207-NQ2012-Database Development (Basic) Student s Handbook

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model

CSE 530A Database Management Systems. Introduction. Washington University Fall 2013

An Engagement Model for Master Data Consumers

Financial Data Access with SQL, Excel & VBA

Technology Foundations. Conan C. Albrecht, Ph.D.

Basics on Geodatabases

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

Database Design and Database Programming with SQL - 5 Day In Class Event Day 1 Activity Start Time Length

CSI 2132 Lab 3. Outline 09/02/2012. More on SQL. Destroying and Altering Relations. Exercise: DROP TABLE ALTER TABLE SELECT

Database Design and Programming

Introduction to Triggers using SQL

Creating Database Tables in Microsoft SQL Server

SQL Server for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

Part 2 - The Database Environment

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

Accessing Your Database with JMP 10 JMP Discovery Conference 2012 Brian Corcoran SAS Institute

Instant SQL Programming

Introduction to SQL ( )

SQL - QUICK GUIDE. Allows users to access data in relational database management systems.

TIM 50 - Business Information Systems

Attribute Data and Relational Database. Lecture 5 9/21/2006

Introduction to SQL for Data Scientists

Chapter 9 Java and SQL. Wang Yang wyang@njnet.edu.cn

DbSchema Tutorial with Introduction in SQL Databases

CSC 443 Data Base Management Systems. Basic SQL

Databases and BigData

Database Design Patterns. Winter Lecture 24

Why do statisticians need to know about databases?

History of Database Systems

Overview of Databases On MacOS. Karl Kuehn Automation Engineer RethinkDB

Database Administration with MySQL

Advance DBMS. Structured Query Language (SQL)

FileMaker 12. ODBC and JDBC Guide

ISM 318: Database Systems. Objectives. Database. Dr. Hamid R. Nemati

Relational Databases and SQLite

The Entity-Relationship Model

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

Database Management System Choices. Introduction To Database Systems CSE 373 Spring 2013

Chapter 1: Introduction. Database Management System (DBMS) University Database Example

A basic create statement for a simple student table would look like the following.


Databases in Engineering / Lab-1 (MS-Access/SQL)

HP Quality Center. Upgrade Preparation Guide

Java and RDBMS. Married with issues. Database constraints

An Introduction to Relational Database Management System

Database Management Systems. Chapter 1

Object Relational Database Mapping. Alex Boughton Spring 2011

Database Design and Normalization

Fundamentals of Database Design

Package sjdbc. R topics documented: February 20, 2015

B.1 Database Design and Definition

Topics. Database Essential Concepts. What s s a Good Database System? Using Database Software. Using Database Software. Types of Database Programs

Chapter 6: Physical Database Design and Performance. Database Development Process. Physical Design Process. Physical Database Design

Database Systems. S. Adams. Dilbert. Available: Hans-Petter Halvorsen, M.Sc.

Chapter 1: Introduction

Database Query 1: SQL Basics

Discovering SQL. Wiley Publishing, Inc. A HANDS-ON GUIDE FOR BEGINNERS. Alex Kriegel WILEY

The process of database development. Logical model: relational DBMS. Relation

CSCE 156H/RAIK 184H Assignment 4 - Project Phase III Database Design

Databases What the Specification Says

Basic Concepts of Database Systems

SQL. Short introduction

Intro to Databases. ACM Webmonkeys 2011

White Paper. PiLab Technology Performance Test, Deep Queries. pilab.pl

1. INTRODUCTION TO RDBMS

Relational Database Concepts

History of SQL. Relational Database Languages. Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG)

Introduction to Relational Database. David Gerbing. School of Business Administration. Portland State University

Relational Databases. Christopher Simpkins

Transcription:

Database Management Systems Rebecca Koskela DataONE University of New Mexico

Databases and the Data Life Cycle Plan Analyze Collect Integrate Assure Discover Describe Preserve 2

Database CollecIon of data stored for a specific purpose Structured data Typically organized by records And relaionships among the records 3

Example Database Systems MicrosoP Access FileMaker MicrosoP SQL Server Oracle IBM DB2 MySQL PostgreSQL SQLite 4

Comparison RDBMS Vendor Start Windows Mac OS Linux Access MicrosoP 1992 x FileMaker FileMaker/ Apple ~1983 x x SQL Server MicrosoP 1989 x Oracle Oracle 1979 x x x DB2 IBM 1983 x x x mysql Sun/Oracle 1995 x x x postgresql SQLite Open source 1989 x x x Open source 2000 x x X 5

Comparison (cont.) RDBMS Access FileMaker SQL Server Oracle DB2 mysql postgresql SQLite Max DB Size 2GB 8 TB 524 258 TB Unlimited 512 TB Unlimited Unlimited 32 TB 6

Advantages of Databases Each piece of data is stored only once Data integraion Field data and lab data Maintains the relaionships among data Easy to subset data Automated reports 7

Spreadsheets vs. Databases Why spreadsheets? Familiarity Drawbacks of spreadsheets: Licle or no protecion against data corrupion Licle or no data validaion Size limitaions 8

Spreadsheets vs. Databases Advantages of databases: MulI- user access Data integrity and data validaion Protect data from inadvertent corrupion Reduce data duplicaion Easy to generate reports Easy to subset data 9

Database Design Goals: Supports required and ad hoc informaion Proper and efficient tables Data integrity imposed at field, table, and relaionship levels Supports business rules Extensible 10

Schema Structure of the database that defines the objects in the database including tables, fields, relaionships Conceptual schema Logical schema Physical schema 11

Conceptual/Logical Schema DescripIon of a paricular collecion of data, using a given data model For a relaional data model, Define eniies (tables) Define acributes (columns) for each enity Specify relaionships between eniies 12

Physical Schema Physical organizaion of the data SQLite, file- based database Reads and writes to ordinary disk files 13

RelaIonships One- to- one: Record in parent table is related to one and only one record in child table One- to- many: Record in parent table is related to zero or more records in child table Many- to- many: MulIple records in parent table are related to muliple records in the child table 14

Maintaining RelaIonships Primary key No intrinsic meaning used to uniquely define a tuple (row) Foreign key Reference to a key in another table implements relaionships between tables 15

EnIty- RelaIonship Diagrams (ERD) EnIty RelaIonship Acribute 16

CreaIng an ERD Researcher collects field data Researcher Date collects Name AffiliaIon ObservaIons LocaIon 17

IdenIfying RelaIonships If enity relaionship is 1- to- 1, use one table If relaionship is 1- to- many, use 2 tables with the primary key of the 1- enity as the foreign key of the many- enity If relaionship is many- to- many, use 3 tables; 1 for each enity and 1 more (FK1,FK2) for mapping the many- to- many relaionship 18

CreaIng an ERD Researcher collects field data Researcher Date Name AffiliaIon collects 1- to- 1? 1- to- many? Many- to- many? ObservaIons LocaIon 19

NormalizaIon Process of organizing the fields and tables of a relaional database to minimize redundancy and dependency Usually involves dividing large tables into smaller (and less redundant) tables and defining relaionships between them ObjecIve is to isolate data so that addiions, deleions, and modificaions of a field can be made in just one table 20

Example Customer ID First Name Surname Telephone 123 Robert Smith 505-861- 2025 456 Jane Wright 505-403- 1659 789 Maria Garcia 505-808- 9633 Added requirement: muliple phone numbers 21

One possibility Customer ID First Name Surname Telephone 1 Telephone 2 123 Robert Smith 505-861- 2025 456 Jane Wright 505-403- 1659 505-776- 4100 789 Maria Garcia 505-808- 9633 Difficulty in querying the table. o "Which customers have telephone number X?" and o "Which pairs of customers share a telephone number? Inability to enforce uniqueness of Customer- to- Telephone Number links through the RDBMS. Database design is imposing constraints on the business process, rather than (as should ideally be the case) vice- versa. 22

Instead CustomerName Customer ID First Name Surname 123 Robert Smith 456 Jane Wright 789 Maria Garcia Customer ID Telephone 123 505-861- 2025 456 505-403- 1659 789 505-808- 9633 456 505-776- 4100 CustomerTelephone 23

Data Types for Acributes Numeric Integer Real, float Text String (varchar) Character Date Stored as text( YY- MM- DD HH:MM:SS.SSS), real (Julian), or integer (Unix Ime) Boolean stored as integers, 0=false, 1=true 24

Null Represents missing or unknown value Not zero Not blank ( ) Not a zero- length string ( ) 25

CreaIng a Database Tables - Start by idenifying all the nouns Acributes RelaIonships among the tables 26

Alaska Asian Avian Influenza Research 27

Center Tasks Collect samples for avian influenza surveillance in Alaska, Russia, Mongolia, and Japan Screen samples by RT- PCR and/or virus isolaion for influenza viruses GeneIc characterizaion of posiive samples Archive samples CI Day 2012 28

Conceptual Schema SemanIcs Avian Influenza project: Birds are captured and swabbed to collect sample that is put in vial with barcode LocaIon, date, species, age, sex, bird band, recapture status are recorded Morphological measurements are taken 29

Logical Schema Data model 1. Define eniies (tables) 2. Define acributes (columns) for each enity 3. Specify relaionships between eniies 30

Field Data Barcode Bird_ID Species Sex/Age Type Location/GPS Date Notes 8BM3001 1837-22186 MALL HYF C Y Lakes N 8/17/08 Recap 8BM3002 934-93127 AGWT AHYM C Y Lakes N 8/17/08 Recap 8BM3003 934-93115 AGWT AHYM C Y Lakes N 8/17/08 Recap 8BM3004 1837-22317 MALL AHYM C Main Channel 8/17/08 8BM3005 1837-22318 MALL AHYM C Main Channel 8/17/08 8BM3006 1837-22319 MALL HYM C Main Channel 8/17/08 8BM3007 1837-22320 MALL AHYF C Main Channel 8/17/08 8BM3008 1837-22321 MALL AHYM C Main Channel 8/17/08 8BM3009 1837-22021 MALL HYF C Main Channel 8/17/08 8BM3010 1096-79463 NOPI AHYM C Main Channel 8/17/08 8BM3011 1146-17396 NOPI AHYM C Cabin 8/17/08 8BM3012 1146-17397 NOPI AHYM C Cabin 8/17/08 8BM3013 1146-17398 NOPI AHYM C Cabin 8/17/08 8BM3014 1146-17399 NOPI HYF C Cabin 8/17/08 8BM3015 1146-17400 NOPI AHYM C Cabin 8/17/08 8BM3016 1146-17401 NOPI HYF C Cabin 8/17/08 8BM3017 1146-17402 NOPI AHYM C Cabin 8/17/08 8BM3018 1146-17403 NOPI HYM C Cabin 8/17/08 8BM3019 1146-17404 NOPI AHYM C Cabin 8/17/08 8BM3020 8BM3021 1146-17405 NOPI AHYF C Cabin 8/17/08 8BM3022 1146-17406 NOPI AHYM C Cabin 8/17/08 8BM3023 1146-17186 NOPI HYM C Cabin 8/17/08 Recap 8BM3024 1096-79466 NOPI HYM C Cabin 8/17/08 Recap 8BM3025 1146-17278 NOPI AHYF C Cabin 8/17/08 Recap 31

Logical Schema Example Physical Schema: Depends on which RDBMS you choose 32

Create Database in SQLite 33

Add a Table 34

Populate the table fields 35

Ensure Integrity You can include some options No blanks allowed Limited Numerical Range 36

Empty Table Ready to Fill 37

SQL Structured Query Language Special- purpose programming language Scope includes data insert, query, update and delete, schema creaion and modificaion 38

Basic SQL SELECT [acribute list] (columns) FROM [relaion] WHERE [condiion] JOIN 39

SELECT SELECT SpeciesName, CommonName FROM Species SELECT SpeciesName, CommonName FROM Species ORDER BY SpeciesName SELECT COUNT(SpeciesName) FROM Species SELECT DISTINCT(SpeciesName) FROM Species SELECT DISTINCT(CommonName) FROM Species 40

SELECT (cont.) SELECT COUNT(SpeciesName) FROM Species SELECT DISTINCT(SpeciesName) FROM Species SELECT DISTINCT(CommonName) FROM Species 41

JOIN SELECT Species.SpeciesName, LocaIon.PlotName FROM Species JOIN LocaIon ON Species.LocaIon = LocaIon.Pkey 42

Databases and the Data Life Cycle Plan Analyze Collect Integrate Assure Discover Describe Preserve 43

QA/QC Data Examples: Check the range of measurements to see if any are out of the expected range Changes in adjacent measurements that are greater than expected Check for duplicate records Check the date and Ime range of the data 44

Databases and the Data Life Cycle Plan Analyze Collect Integrate Assure Discover Describe Preserve 45

Other SQL FuncIons FuncIons for descripive staisics: COUNT() MAX(), MIN(), AVE() DISTINCT ORDER BY GROUP BY 46

Databases and the Data Life Cycle Plan Analyze Collect Integrate Assure Discover Describe Preserve 47

June 3 through June 21, 2013 University of New Mexico 48