2014.10.30 SLIDE 1IS 257 – Fall 2014 NoSQL Databases University of California, Berkeley School of Information IS 257: Database Management.

Slides:



Advertisements
Similar presentations
SLIDE 1IS Fall 2002 Data Administration and Database Administration University of California, Berkeley School of Information Management.
Advertisements

SLIDE 1IS Fall 2002 Extending Object-Relational Database Systems University of California, Berkeley School of Information Management.
SLIDE 1IS Fall 2002 Fourth Generation Languages and OR extensions to SQL University of California, Berkeley School of Information Management.
Fall 2001Arthur Keller – CS 1808–1 Schedule Today Oct. 18 (TH) Schemas, Views. u Read Sections u Project Part 3 extended to Oct. 23 (T). Oct.
SLIDE 1IS 257 – Fall 2011 Object-Relational Databases and OR Extensions University of California, Berkeley School of Information IS 257: Database.
Winter 2002Arthur Keller – CS 1808–1 Schedule Today: Jan. 29 (T) u Modifications, Schemas, Views. u Read Sections Assignment 3 due. Jan. 31 (TH)
IS 4420 Database Fundamentals Chapter 6: Physical Database Design and Performance Leon Chen.
SLIDE 1IS Fall 2002 Object-Oriented, Intelligent and Object-Relational Database Models University of California, Berkeley School of Information.
Oracle Objects Object Oriented Database Approach.
SLIDE 1IS 257 – Spring 2004 Data Administration and Database Administration University of California, Berkeley School of Information Management.
SLIDE 1IS 257 – Fall 2006 Object-Relational Databases and OR Extensions University of California, Berkeley School of Information IS 257: Database.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
SLIDE 1IS 257 – Spring 2004 Object-Relational Database System Features University of California, Berkeley School of Information Management.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
11/7/2000Database Management -- R. Larson Object-Oriented, Intelligent and Object-Relational Database Models University of California, Berkeley School.
SLIDE 1IS Fall 2002 Fourth Generation Languages and OR extensions to SQL University of California, Berkeley School of Information Management.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch Via Yoonsuck Choe.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 6 1 © Prentice Hall, 2002 The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited) Project Identification and Selection Project Initiation.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 4th Edition Copyright © 2009 John Wiley & Sons, Inc. All rights.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
CSC 2720 Building Web Applications Database and SQL.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
CpSc 462/662: Database Management Systems (DBMS) (TEXNH Approach) Constraints, Triggers and Index James Wang.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2015, Fred McClurg, All Rights.
11 3 / 12 CHAPTER Databases MIS105 Lec15 Irfan Ahmed Ilyas.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
CpSc 462/662: Database Management Systems (DBMS) (TEXNH Approach) Stored Procedure James Wang.
Chapter 5 MYSQL Database. Introduction to MYSQL MySQL is the world's most popular open-source database. Open source means that the source code, the programming.
SQL CMSC 461 Michael Wilson. Finally, some code  This is where the theory and practice actually come together  Basically taking the relational algebra.
SCUHolliday - coen 1788–1 Schedule Today u Modifications, Schemas, Views. u Read Sections (except and 6.6.6) Next u Constraints. u Read.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Advanced Database CS-426 Week 1 - Introduction. Database Management System DBMS contains information about a particular enterprise Collection of interrelated.
Visual Programing SQL Overview Section 1.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Introduction Object Oriented (OO) Data Models since mid-90’s Reasons for creation of.
IS 380 Introduction to SQL This lectures covers material from: database textbook chapter 3 Oracle chapter: 3,14,17.
GLOBEX INFOTEK Copyright © 2013 Dr. Emelda Ntinglet-DavisSYSTEMS ANALYSIS AND DESIGN METHODSINTRODUCTORY SESSION EFFECTIVE DATABASE DESIGN for BEGINNERS.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
CpSc 462/662: Database Management Systems (DBMS) (TEXNH Approach) Views, Constraints, Triggers and Index James Wang.
© D. Wong Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:
CMPT 258 Database Systems The Relationship Model (Chapter 3)
1 MySQL and SQL. 2 Topics  Introducing Relational Databases  Terminology  Managing Databases MySQL and SQL.
DBTech VET / DBTechNet SQL Transactions Stored Procedures BY EXAMPLE: Triggers, Functions, Procedures, Cursors November 2014 Christos Skourlas
Relational Databases and MySQL. Relational Databases Relational databases model data by storing rows and columns in tables. The power of the relational.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 5th Edition Copyright © 2015 John Wiley & Sons, Inc. All rights.
1 Stored Procedures in MySQL Part I. 2 Objectives SQL Vs. MySQL SP MySQL SP Parameters MySQL SP Control Structures.
1 Part IV: Object-Relational Databases  Ch. 30: Types, Object Views, Methods  Ch. 31: Nested Tables and Varying Arrays  Ch. 32: Large Objects  Ch.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
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.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
Introduction to Database Programming with Python Gary Stewart
Object-Relational Databases and OR Extensions
Chapter 5 Introduction to SQL.
CS320 Web and Internet Programming SQL and MySQL
SQL OVERVIEW DEFINING A SCHEMA
Object-Relational Features
CS3220 Web and Internet Programming SQL and MySQL
Chapter 4 Introduction to MySQL.
CS3220 Web and Internet Programming SQL and MySQL
Presentation transcript:

SLIDE 1IS 257 – Fall 2014 NoSQL Databases University of California, Berkeley School of Information IS 257: Database Management

SLIDE 2IS 257 – Fall 2014 Lecture Outline Review –Object-Relational DBMS OR features in Oracle OR features in PostgreSQL –Extending OR databases (examples from PostgreSQL) NoSQL Databases

SLIDE 3IS 257 – Fall 2014 Lecture Outline Review –Object-Relational DBMS OR features in Oracle OR features in PostgreSQL –Extending OR databases (examples from PostgreSQL) NoSQL Databases

SLIDE 4IS 257 – Fall 2014 Example CREATE TYPE ANIMAL_TY AS OBJECT (Breed VARCHAR2(25), Name VARCHAR2(25), Birthdate DATE); –Creates a new type CREATE TABLE Animal of Animal_ty; –Creates “Object Table”

SLIDE 5IS 257 – Fall 2014 Constructor Functions INSERT INTO Animal values (ANIMAL_TY(‘Mule’, ‘Frances’, TO_DATE(‘01-APR-1997’, ‘DD-MM- YYYY’))); –Insert a new ANIMAL_TY object into the table

SLIDE 6IS 257 – Fall 2014 Selecting from an Object Table Just use the columns in the object… SELECT Name from Animal;

SLIDE 7IS 257 – Fall 2014 More Complex Objects CREATE TYPE Address_TY as object (Street VARCHAR2(50), City VARCHAR2(25), State CHAR(2), zip NUMBER); CREATE TYPE Person_TY as object (Name VARCHAR2(25), Address ADDRESS_TY); CREATE TABLE CUSTOMER (Customer_ID NUMBER, Person PERSON_TY);

SLIDE 8IS 257 – Fall 2014 What Does the Table Look like? DESCRIBE CUSTOMER; NAME TYPE CUSTOMER_ID NUMBER PERSON NAMED TYPE

SLIDE 9IS 257 – Fall 2014 Inserting INSERT INTO CUSTOMER VALUES (1, PERSON_TY(‘John Smith’, ADDRESS_TY(‘57 Mt Pleasant St.’, ‘Finn’, ‘NH’, )));

SLIDE 10IS 257 – Fall 2014 Selecting from Abstract Datatypes SELECT Customer_ID from CUSTOMER; SELECT * from CUSTOMER; CUSTOMER_ID PERSON(NAME, ADDRESS(STREET, CITY, STATE ZIP)) PERSON_TY( ‘ JOHN SMITH ’, ADDRESS_TY( ‘ 57...

SLIDE 11IS 257 – Fall 2014 Selecting from Abstract Datatypes SELECT Customer_id, person.name from Customer; SELECT Customer_id, person.address.street from Customer;

SLIDE 12IS 257 – Fall 2014 Updating UPDATE Customer SET person.address.city = ‘HART’ where person.address.city = ‘Briant’;

SLIDE 13IS 257 – Fall 2014 User-Defined Functions (Oracle) CREATE [OR REPLACE] FUNCTION funcname (argname [IN | OUT | IN OUT] datatype …) RETURN datatype (IS | AS) {block | external body}

SLIDE 14IS 257 – Fall 2014 Example Create Function BALANCE_CHECK (Person_name IN Varchar2) RETURN NUMBER is BALANCE NUMBER(10,2) BEGIN SELECT sum(decode(Action, ‘BOUGHT’, Amount, 0)) - sum(decode(Action, ‘SOLD’, amount, 0)) INTO BALANCE FROM LEDGER where Person = PERSON_NAME; RETURN BALANCE; END;

SLIDE 15IS 257 – Fall 2014 Example Select NAME, BALANCE_CHECK(NAME) from Worker;

SLIDE 16IS 257 – Fall 2014 Functions and Procedures - MySQL CREATE [DEFINER = { user | CURRENT_USER }] PROCEDURE sp_name ([proc_parameter[,...]]) [characteristic...] routine_body CREATE [DEFINER = { user | CURRENT_USER }] FUNCTION sp_name ([func_parameter[,...]]) RETURNS type [characteristic...] routine_body proc_parameter: [ IN | OUT | INOUT ] param_name type func_parameter: param_name type type: Any valid MySQL data type characteristic: LANGUAGE SQL | [NOT] DETERMINISTIC | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA } | SQL SECURITY { DEFINER | INVOKER } | COMMENT 'string' routine_body: Valid SQL procedure statement

SLIDE 17IS 257 – Fall 2014 Defining a MySQL procedure mysql> delimiter // mysql> CREATE PROCEDURE simpleproc (OUT param1 INT) -> BEGIN -> SELECT COUNT(*) INTO param1 FROM t; -> END// Query OK, 0 rows affected (0.00 sec) mysql> delimiter ; mysql> CALL Query OK, 0 rows affected (0.00 sec) mysql> | | 3 | row in set (0.00 sec)

SLIDE 18IS 257 – Fall 2014 Defining a MySQL Function mysql> CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50) DETERMINISTIC -> RETURN CONCAT('Hello, ',s,'!'); Query OK, 0 rows affected (0.00 sec) mysql> SELECT hello('world'); | hello('world') | | Hello, world! | row in set (0.00 sec)

SLIDE 19IS 257 – Fall 2014 TRIGGERS (Oracle) Create TRIGGER UPDATE_LODGING INSTEAD OF UPDATE on WORKER_LODGING for each row BEGIN if :old.name <> :new.name then update worker set name = :new.name where name = :old.name; end if; if :old.lodging <> … etc...

SLIDE 20IS 257 – Fall 2014 Triggers in MySQL CREATE [DEFINER = { user | CURRENT_USER }] TRIGGER trigger_name trigger_time trigger_event ON tbl_name FOR EACH ROW trigger_stmt trigger_event can be INSERT, UPDATE, or DELETE trigger_time can be BEFORE or AFTER.

SLIDE 21IS 257 – Fall 2014 Triggers in MySQL CREATE TABLE test1(a1 INT); CREATE TABLE test2(a2 INT); CREATE TABLE test3(a3 INT NOT NULL AUTO_INCREMENT PRIMARY KEY); CREATE TABLE test4( a4 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b4 INT DEFAULT 0 ); delimiter | CREATE TRIGGER testref BEFORE INSERT ON test1 FOR EACH ROW BEGIN INSERT INTO test2 SET a2 = NEW.a1; DELETE FROM test3 WHERE a3 = NEW.a1; UPDATE test4 SET b4 = b4 + 1 WHERE a4 = NEW.a1; END | delimiter ;

SLIDE 22IS 257 – Fall 2014 Triggers in MySQL (cont) mysql> INSERT INTO test3 (a3) VALUES (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL); mysql> INSERT INTO test4 (a4) VALUES (0), (0), (0), (0), (0), (0), (0), (0), (0), (0); mysql> INSERT INTO test1 VALUES -> (1), (3), (1), (7), (1), (8), (4), (4); mysql> SELECT * FROM test1; | a1 | | 1 | | 3 | | 1 | | 7 | | 1 | | 8 | | 4 |

SLIDE 23IS 257 – Fall 2014 Triggers in MySQL (cont.) mysql> SELECT * FROM test2; | a2 | | 1 | | 3 | | 1 | | 7 | | 1 | | 8 | | 4 | mysql> SELECT * FROM test3; | a3 | | 2 | | 5 | | 6 | | 9 | | 10 | mysql> SELECT * FROM test4; | a4 | b4 | | 1 | 3 | | 2 | 0 | | 3 | 1 | | 4 | 2 | | 5 | 0 | | 6 | 0 | | 7 | 1 | | 8 | 1 | | 9 | 0 | | 10 | 0 |

SLIDE 24IS 257 – Fall 2014 PostgreSQL Derived from POSTGRES –Developed at Berkeley by Mike Stonebraker and his students (EECS) starting in 1986 Postgres95 –Andrew Yu and Jolly Chen adapted POSTGRES to SQL and greatly improved the code base PostgreSQL –Name changed in 1996, and since that time the system has been expanded to support most SQL92 and many SQL99 features

SLIDE 25IS 257 – Fall 2014 PostgreSQL All of the usual SQL commands for creation, searching and modifying classes (tables) are available. With some additions… Inheritance Non-Atomic Values User defined functions and operators

SLIDE 26IS 257 – Fall 2014 Inheritance In Postgres, a class can inherit from zero or more other classes. A query can reference either –all instances of a class –or all instances of a class plus all of its descendants

SLIDE 27IS 257 – Fall 2014 Inheritance ray=# create table cities (name varchar(50), population float, altitude int); CREATE TABLE ray=# \d cities Table "public.cities" Column | Type | Modifiers name | character varying(50) | population | double precision | altitude | integer | ray=# create table capitals (state char(2)) inherits (cities); CREATE TABLE ray=# \d capitals Table "public.capitals" Column | Type | Modifiers name | character varying(50) | population | double precision | altitude | integer | state | character(2) | Inherits: cities

SLIDE 28IS 257 – Fall 2014 Inheritance For example, the following query finds all the cities that are situated at an attitude of 500ft or higher: SELECT name, altitude FROM cities WHERE altitude > 500; |name | altitude | |Las Vegas | 2174 | |Mariposa | 1953 |

SLIDE 29IS 257 – Fall 2014 Inheritance On the other hand, to find the names of all cities, including state capitals, that are located at an altitude over 500ft, the query is: SELECT c.name, c.altitude FROM cities* c WHERE c.altitude > 500; which returns: |name | altitude | |Las Vegas | 2174 | |Mariposa | 1953 | |Madison | 845 |

SLIDE 30IS 257 – Fall 2014 Non-Atomic Values - Arrays Postgres allows attributes of an instance to be defined as fixed-length or variable-length multi- dimensional arrays. Arrays of any base type or user-defined type can be created. To illustrate their use, we first create a class with arrays of base types. CREATE TABLE SAL_EMP ( name text, pay_by_quarter int4[], schedule text[][] );

SLIDE 31IS 257 – Fall 2014 Postgres System Catalogs

SLIDE 32 NoSQL Introduction Presentation from Keith Hare NoSQL Database Architecture IS 257 – Fall 2014

SLIDE 33 NoSQL Database Architectures IS 257 – Fall 2014

SLIDE 34 NoSQL Database NoSQL databases use a variety of file structures and access methods for their operation There is very little commonality across the different NoSQL DBs in terms of file storage We will look at a couple of examples –BerkeleyDB – the grand-daddy of NoSQL DBs –MongoDB – One of the best known NoSQL DBs IS 257 – Fall 2014

SLIDE 35 BerkeleyDB Architecture IS 257 – Fall 2014

SLIDE 36 BerkeleyDB The system provides three types of underlying file DBMS access methods –RecordID –Btree –Hashed RecordID is a simple numeric record lookup Btree uses clever caching to keep the frequently used and higher tree levels in memory Hash uses extensible hashing IS 257 – Fall 2014

SLIDE 37 MongoDB Storage MongoDB uses memory-mapped files for data storage A memory-mapped file is a file with data that the operating system places in memory by way of the mmap() system call. mmap() thus maps the file to a region of virtual memory. Memory-mapped files are the critical piece of the storage engine in MongoDB. By using memory mapped files MongoDB can treat the contents of its data files as if they were in memory. IS 257 – Fall 2014

SLIDE 38 MongoDB Storage This provides MongoDB with an extremely fast and simple method for accessing and manipulating data. Memory mapping assigns files to a block of virtual memory with a direct byte-for- byte correlation. Once mapped, the relationship between file and memory allows MongoDB to interact with the data in the file as if it were memory. IS 257 – Fall 2014

SLIDE 39 MongoDB Storage How does MongoDB work with memory mapped files? MongoDB uses memory mapped files for managing and interacting with all data. MongoDB memory maps data files to memory as it accesses documents. Data that isn’t accessed is not mapped to memory. IS 257 – Fall 2014

SLIDE 40 IS 257 – Fall 2014