PostgreSQL and relational databases As well as assignment 4…

Slides:



Advertisements
Similar presentations
Chapter 10: Designing Databases
Advertisements

CC SQL Utilities.
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.
CIT 613: Relational Database Development using SQL Introduction to SQL.
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.
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.
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.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Chapter 12 Information Systems Nell Dale John Lewis.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
APPENDIX C DESIGNING DATABASES
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
SQL Basics+ Brandon Checketts. Why SQL? Structured Query Language Structured Query Language Frees programmers from dealing with specifics of data persistence.
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.
CSCI 6962: Server-side Design and Programming
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
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.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
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.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
PostgreSQL and relational databases As well as assignment 4…
NOSQL DATABASES Please remember to read the NOSQL Distilled book and the Seven Databases book.
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.
FEN  Data Definition: CREATE TABLE, ALTER TABLE  Data Manipulation: INSERT, UPDATE, DELETE  Queries: SELECT SQL: Structured Query Language.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
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.
Reactive Database Access in Scala with Slick 3
M1G Introduction to Database Development 2. Creating a Database.
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…
7 1 Constraints & Triggers Chapter Constraints and triggers? Constraints: Certain properties that the DBMS is required to enforce –E.g. primary.
1 DBS201: More on SQL Lecture 3. 2 Agenda How to use SQL to update table definitions How to update data in a table How to join tables together.
Database Management Systems (DBMS)
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
CIT 613: Relational Database Development using SQL Introduction to SQL DeSiaMorePowered by DeSiaMore 1.
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.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
IMS 4212: Constraints & Triggers 1 Dr. Lawrence West, Management Dept., University of Central Florida Stored Procedures in SQL Server.
Table Structures and Indexing. The concept of indexing If you were asked to search for the name “Adam Wilbert” in a phonebook, you would go directly to.
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.
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.
SQL Basics Review Reviewing what we’ve learned so far…….
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
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Database Management  .
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 …..