PostgreSQL and relational databases As well as assignment 4…

Slides:



Advertisements
Similar presentations
Chapter 10: Designing Databases
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.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
SQL This presentation will cover: A Brief History of DBMS View in database MySQL installation.
Results of the survey and relational dbs Fall 2011.
Database Management System Module 3:. Complex Constraints In this we specify complex integrity constraints included in SQL. It relates to integrity constraints.
Calendar Browser is a groupware used for booking all kinds of resources within an organization. Calendar Browser is installed on a file server and in a.
The Relational Model Class 2 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) (From ER to Relational)
Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
Cs3431 Constraints Sections 6.1 – 6.5. cs3431 Example CREATE TABLE Student ( sNum int, sName varchar (20), prof int, CONSTRAINT pk PRIMARY KEY (snum),
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 28 Database Systems I The Relational Data Model.
CSE 190: Internet E-Commerce Lecture 10: Data Tier.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
The Relational Model Lecture 3 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) From ER to Relational.
M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #15 M.P. Johnson Stern School of Business, NYU Spring, 2005.
Attribute databases. GIS Definition Diagram Output Query Results.
APPENDIX C DESIGNING DATABASES
SQL Basics+ Brandon Checketts. Why SQL? Structured Query Language Structured Query Language Frees programmers from dealing with specifics of data persistence.
Database Systems Lecture 5 Natasha Alechina
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
 Schema-less databases Really…? In actuality, there is no such thing as a schema-less database In a relational database, the schema is explicit and created.
Database Principles Relational Database Design I.
CSCI 6962: Server-side Design and Programming
Databases From A to Boyce Codd. What is a database? It depends on your point of view. For Manovich, a database is a means of structuring information in.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
The Relational Model These slides are based on the slides of your text book.
PostgreSQL and relational databases As well as assignment 4…
The Relational Model. Review Why use a DBMS? OS provides RAM and disk.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Databases. Database A database is an organized collection of related data.
Copyright  Oracle Corporation, All rights reserved. 4 CMIS Powell Oracle Designer: Creating the Database Design CMIS Powell.
Dbwebsites 2.1 Making Database backed Websites Session 2 The SQL… Where do we put the data?
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
Database Management System Lecture 4 The Relational Database Model- Introduction, Relational Database Concepts.
NOSQL DATABASES Please remember to read the NOSQL Distilled book and the Seven Databases book.
Fundamentals of Relational Database Operations
1 What is database 2? What is normalization? What is SQL? What is transaction?
Natural vs. Generated Keys. Definitions Natural key—a key that occurs in the data, that uniquely identifies rows. AKA candidate key. Generated key—a key.
Organizing Data Revision: pages 8-10, 31 Chapter 3.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Chapter 10: The Data Tier We discuss back-end data storage for Web applications, relational data, and using the MySQL database server for back-end storage.
M1G Introduction to Database Development 2. Creating a Database.
10/10/2012ISC239 Isabelle Bichindaritz1 Physical Database Design.
FEN Introduction to the database field:  The Relational Model Seminar: Introduction to relational databases.
Constraints, Triggers and Views COMSATS INSTITUTE OF INFORMATION TECHNOLOGY, VEHARI.
Advanced SQL: Triggers & Assertions
Fall 2013, Databases, Exam 2 Questions for the second exam…
Fox MIS Spring 2011 Database Week 6 ERD and SQL Exercise.
Database Systems Lecture 1. In this Lecture Course Information Databases and Database Systems Some History The Relational Model.
Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin APPENDIX C DESIGNING DATABASES APPENDIX C DESIGNING DATABASES.
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
IS6146 Databases for Management Information Systems Lecture 3: SQL III – The DDL Rob Gleasure robgleasure.com.
The relational model1 The relational model Mathematical basis for relational databases.
FEN Introduction to the database field: The development process Seminar: Introduction to relational databases Development process: Analyse.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Murali Mani Constraints. Murali Mani Keys: Primary keys and unique CREATE TABLE Student ( sNum int, sName varchar (20), dept char (2), CONSTRAINT key.
Chapter 3 The Relational Model. Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. “Legacy.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
Data generators by Jan Kincl. Data Generators - Jan Kincl2 Outline Introduction Introduction Main features Main features MySQL Data Generators MySQL Data.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
CS320 Web and Internet Programming SQL and MySQL
CIS 336 Competitive Success/snaptutorial.com
CIS 336 Education for Service-- snaptutorial.com.
CIS 336 Teaching Effectively-- snaptutorial.com
CS3220 Web and Internet Programming SQL and MySQL
Presentation transcript:

PostgreSQL and relational databases As well as assignment 4…

Reflections on relational DBs Reasons for using a relational database Data fits nicely on one server and is used locally We need absolute correctness for our data – remember, once there is any error at all, we cannot provide a quantitative description of just how bad it might be We have a pile of programmers who know and love SQL We need our queries/updates to be carefully vetted and stored for security on the server, with no other queries/updates running Our data is highly and repetitively structured We need to heavily optimize our queries for very high volume repetition Our database will be fairly stable structurally and there is downtime that can be used to make schema and mass data updates We don’t want to use two different database technologies and we already know we need a relational database for at least part of our data We want a db technology that is widely used and trusted and that is well understood by the software community as a whole We don’t want to risk using a db technology that might change or go away the day after tomorrow

PostgreSQL vs. MySQL PostgreSQL is a generation newer It has nice UDT capabilities There are libraries of UDTs that can be imported and used Both PostgreSQL and MySQL Full text search XML data types To some degree free MySQL Never underestimate the value of a heavily understood piece of software Lots of stacks and development environments come configured to work with it (but to a lesser extent, this is true of PostgreSQL, too). It is a “core” SQL database, in that we can move pretty much to any other server- based DBMS is we start with MySQL

Installing PostgreSQL   

PostgreSQL install, continued  Go to:

Using PostgreSQL

Using PostgreSQL, continued

Assignment 4: Overview You will build an application using PostgreSQL and Cassandra The application will consist of a handful of operations that you will perform on each database – you can run your operations manually and have no app PostgreSQL will hold your schema based, tabular data But only the most recent data Cassandra will hold your schema-variable data and will be comprehensive over time The operations you run on the Cassandra table will make use of timestamps This is due at the beginning of class on Feb. 25.

Assignment 4: Tables There will be two tables in PostgreSQL The first holds customers who are buying items Key for customer, customer name, item purchased for each row (FK of primary key of second table) Note that will only keep the most recent purchase in the table. The second will hold the items for purchase Key for item; price for item; an overview of the item, which contains two fields, an item description and the market where the item is sold (U.S., Colorado, or something like that). Note we only keep the most recent price for each item. Cassandra will hold the buying history of each customer What items purchased How many of each item Price paid all of the instances of a given item – prices can change over time

Assignment 4: Operations   You will need to:  create 2 tables in PostgreSQL  create a table in Cassandra  search the Cassandra table by customer and return the total amount spent to date for a given customer  search the Cassandra table by customer and return the price paid for a given item and the date it was bought; note that an item can be bought more than once and at different prices  create rows for tables in PostgreSQL, making sure to always replace a previous tuple if the primary key is already in the table

UDTs in PostgreSQL  For extra credit, put a Two important operators:  Create domain  Does not support the making of complex types  You can create an alias for a built-in data type and specify the rang  You can also specify a default value and null/not null.  Create Type  Does not support nulls or default values  Either of them can be used to create enumerated types  A composite type contains more than one field

Example Create statements CREATE DOMAIN addresss VARCHAR(50) NOT NULL CREATE DOMAIN age INT CHECK (VALUE > 0 AND VALUE < 120) Note: you can add check constraints to a create domain specification, but not to a type definition CREATE TYPE addresses AS ( city VARCHAR(10), street VARCHAR(40), zip INTEGER)

Example inserts INSERT INTO people VALUES (‘t1', ‘wash car‘); INSERT INTO myhobbies VALUES (myid, (“raise chickens”, “eat chickens”));

Postgis  Geographic extensions for PostgreSQL   Download 32 bit for windows  Provides  Basic 2d types: points, lines, polygons, etc.  Spatial operators: area, distance, etc.  Some 3d support  Lets us ask questions like: do these two places overlap?

GIS

Assignment 5…  Use the GIS database …..

Questions on midterm The two books and the posted slides are important No code writing Questions will be conceptual, but each will have a specific answer No essays or subjective material We will review for the midterm on March 6 Example questions 1. You are going to build an application to manage the movement of energy on a grid. Of the db systems we have discussed in class, which would you use and why? 2. What is polyglot persistence? 3. When we say there is a tradeoff between correctness and speed (or throughput), what do we mean? 4. What is a database “migration”? 5. What is the difference between a key-value db and a key-document db? 6. Take the following relational table and put it in 1 st normal form (I would give you the attributes of the table, the PK, the FDs and the MVDs).