CPT-S 483-05 Topics in Computer Science Big Data 1 1 Yinghui Wu EME 49.

Slides:



Advertisements
Similar presentations
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Advertisements

2P13 Week 11. A+ Guide to Managing and Maintaining your PC, 6e2 RAID Controllers Redundant Array of Independent (or Inexpensive) Disks Level 0 -- Striped.
NoSQL Databases: MongoDB vs Cassandra
Topic Denormalisation S McKeever Advanced Databases 1.
BTrees & Bitmap Indexes
IS 4420 Database Fundamentals Chapter 6: Physical Database Design and Performance Leon Chen.
Efficient Storage and Retrieval of Data
Graph databases …the other end of the NoSQL spectrum. Material taken from NoSQL Distilled and Seven Databases in Seven Weeks.
Lecture 6 Indexing Part 2 Column Stores. Indexes Recap Heap FileBitmapHash FileB+Tree InsertO(1) O( log B n ) DeleteO(P)O(1) O( log B n ) Range Scan O(P)--
An introduction to MongoDB Rácz Gábor ELTE IK, febr. 10.
Introduction to Column-Oriented Databases Seminar: Columnar Databases, Nov 2012, Univ. Helsinki.
Databases with Scalable capabilities Presented by Mike Trischetta.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Cloud Computing Lecture Column Store – alternative organization for big relational data.
Systems analysis and design, 6th edition Dennis, wixom, and roth
Practical Database Design and Tuning. Outline  Practical Database Design and Tuning Physical Database Design in Relational Databases An Overview of Database.
1 © Prentice Hall, 2002 Physical Database Design Dr. Bijoy Bordoloi.
MongoDB An introduction. What is MongoDB? The name Mongo is derived from Humongous To say that MongoDB can handle a humongous amount of data Document.
CS 345: Topics in Data Warehousing Tuesday, October 19, 2004.
HBase A column-centered database 1. Overview An Apache project Influenced by Google’s BigTable Built on Hadoop ▫A distributed file system ▫Supports Map-Reduce.
TM 7-1 Copyright © 1999 Addison Wesley Longman, Inc. Physical Database Design.
Goodbye rows and tables, hello documents and collections.
Physical Database Design Chapter 6. Physical Design and implementation 1.Translate global logical data model for target DBMS  1.1Design base relations.
DANIEL J. ABADI, ADAM MARCUS, SAMUEL R. MADDEN, AND KATE HOLLENBACH THE VLDB JOURNAL. SW-Store: a vertically partitioned DBMS for Semantic Web data.
Chapter 6 1 © Prentice Hall, 2002 The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited) Project Identification and Selection Project Initiation.
NoSQL Databases Oracle - Berkeley DB. Content A brief intro to NoSQL About Berkeley Db About our application.
Column-Stores vs. Row-Stores How Different are they Really? Daniel J. Abadi, Samuel Madden, and Nabil Hachem, SIGMOD 2008 Presented By, Paresh Modak( )
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
Chapter 16 Practical Database Design and Tuning Copyright © 2004 Pearson Education, Inc.
C-Store: How Different are Column-Stores and Row-Stores? Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY May. 8, 2009.
1 CS 430 Database Theory Winter 2005 Lecture 16: Inside a DBMS.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Architecture.
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.
MongoDB is a database management system designed for web applications and internet infrastructure. The data model and persistence strategies are built.
1 Biometric Databases. 2 Overview Problems associated with Biometric databases Some practical solutions Some existing DBMS.
C-Store: Data Model and Data Organization Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY May 17, 2010.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Introduction.  Administration  Simple DBMS  CMPT 454 Topics John Edgar2.
MongoDB First Light. Mongo DB Basics Mongo is a document based NoSQL. –A document is just a JSON object. –A collection is just a (large) set of documents.
Lec 7 Practical Database Design and Tuning Copyright © 2004 Pearson Education, Inc.
Chapter 5 Index and Clustering
Session 1 Module 1: Introduction to Data Integrity
NoSQL Or Peles. What is NoSQL A collection of various technologies meant to work around RDBMS limitations (mostly performance) Not much of a definition...
NOSQL DATABASE Not Only SQL DATABASE
NoSQL: Graph Databases. Databases Why NoSQL Databases?
CSC 143T 1 CSC 143 Highlights of Tables and Hashing [Chapter 11 p (Tables)] [Chapter 12 p (Hashing)]
Column Oriented Database By: Deepak Sood Garima Chhikara Neha Rani Vijayita Gumber.
SQL Basics Review Reviewing what we’ve learned so far…….
Introduction to Database Programming with Python Gary Stewart
COMP 430 Intro. to Database Systems MongoDB. What is MongoDB? “Humongous” DB NoSQL, no schemas DB Lots of similarities with SQL RDBMs, but with more flexibility.
Column-Stores vs. Row-Stores How Different are they Really? Daniel J. Abadi, Samuel Madden, and Nabil Hachem, SIGMOD 2008: Talk by Karthik Ramachandra,
CSE-291 (Distributed Systems) Winter 2017 Gregory Kesden
and Big Data Storage Systems
Cloud Computing and Architecuture
Practical Database Design and Tuning
Module 11: File Structure
CPT-S 415 Big Data Yinghui Wu EME B45 1.
Record Storage, File Organization, and Indexes
MongoDB Er. Shiva K. Shrestha ME Computer, NCIT
CPT-S 415 Big Data Yinghui Wu EME B45 1.
Physical Database Design for Relational Databases Step 3 – Step 8
NOSQL databases and Big Data Storage Systems
CSE-291 (Cloud Computing) Fall 2016 Gregory Kesden
CHAPTER 5: PHYSICAL DATABASE DESIGN AND PERFORMANCE
1 Demand of your DB is changing Presented By: Ashwani Kumar
Physical Database Design
Practical Database Design and Tuning
The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited)
Database management concepts
CSTORE E0261 Jayant Haritsa Computer Science and Automation
Presentation transcript:

CPT-S Topics in Computer Science Big Data 1 1 Yinghui Wu EME 49

2 CPT-S Big Data Beyond Relational Data noSQL databases Document DBs - MongoDB Column family Graph databases

What is MongoDB? Developed by 10gen: “ humongous ” DB Founded in 2007 A document-oriented NoSQL database Hash-based, schema-less database No Data Definition Language can store hashes with any keys and values that you choose Keys are a basic data type but in reality stored as strings Document Identifiers (_id) will be created for each document, field name reserved by system Uses BSON format Based on JSON – B stands for Binary Supports APIs (drivers) in many computer languages JavaScript, Python, Ruby, Perl, Java, Java Scala, C#, C++, Haskell, Erlang 17

MongoDB: CAP approach Focus on Consistency and Partition tolerance Consistency all replicas contain the same version of the data Availability system remains operational on failing nodes Partition tolarence multiple entry points system remains operational on system split CAP Theorem: satisfying all three at the same time is impossible 20 AP C

Functionality of MongoDB Dynamic schema No DDL Document-based database Secondary indexes Query language via an API Atomic writes and fully-consistent reads If system configured that way Master-slave replication with automated failover (replica sets) Built-in horizontal scaling via automated range-based partitioning of data (sharding) No joins nor transactions 5

Why use MongoDB? Application need Simple queries Functionality provided applicable to most web applications Easy and fast integration of data Not well suited for heavy and complex transactions systems 6 MongoDB Features Document-Oriented storage Full Index Support Replication & High Availability Auto-Sharding Ad-hoc Querying Fast In-Place Updates Map/Reduce functionality

MongoDB: Hierarchical Objects A MongoDB instance may have zero or more ‘databases’ A database may have zero or more ‘collections’. A collection may have zero or more ‘documents’. A document may have one or more ‘fields’. MongoDB ‘Indexes’ function much like their RDBMS counterparts. 0 or more Databases 0 or more Collections 0 or more Documents 0 or more Fields

RDB Concepts to NO SQL RDBMSMongoDB Database Table, ViewCollection RowDocument (BSON) ColumnField Index JoinEmbedded Document Foreign KeyReference PartitionShard

BSON “Binary JSON” Binary-encoded serialization of JSON-like docs Also allows “referencing” Embedded structure reduces need for joins Goals –Lightweight –Traversable –Efficient (decoding and encoding)

The _id Field By default, each document contains an _id field. This field has a number of special characteristics: –Value serves as primary key for collection. –Value is unique, immutable, and may be any non-array type. –Default data type is ObjectId, which is “small, likely unique, fast to generate, and ordered.” -types/ { "_id" : "37010" "city" : "ADAMS", "pop" : 2660, "state" : "TN",}

BSON Example { "_id" : "37010" "city" : "ADAMS", "pop" : 2660, "state" : "TN", “councilman” : { name: “John Smith” address: “13 Scenic Way” } { {“_id” : “1” “first name”: “Hassan” “last name” : “Mir” “department”: 20 } {“_id” : “1” “first name”: “Bill” “last name” : “Gates” }

CRUD Create –db.collection.insert( ) –db.collection.save( ) –db.collection.update(,, { upsert: true } ) Read –db.collection.find(, ) –db.collection.findOne(, ) Update –db.collection.update(,, ) Delete –db.collection.remove(, )

CRUD example > db.user. insert ({ first: "John", last : "Doe", age: 39 }) > db.user. insert ({ first: "John", last : "Doe", age: 39 }) > db.user.find () { "_id" : ObjectId("51…"), "first" : "John", "last" : "Doe", "age" : 39 } > db.user.find () { "_id" : ObjectId("51…"), "first" : "John", "last" : "Doe", "age" : 39 } > db.user.update( {"_id" : ObjectId("51…")}, { $set: { age: 40, salary: 7000} } ) > db.user.update( {"_id" : ObjectId("51…")}, { $set: { age: 40, salary: 7000} } ) > db.user.remove({ "first": /^J/ })

Replication of data Ensures redundancy, backup, and automatic failover Recovery manager in the RDMS Replication through groups of servers known as replica sets Primary set – set of servers that client tasks direct updates to Secondary set – set of servers used for duplication of data If the primary set fails the secondary sets ‘vote’ to elect the new primary set

15 Replica Sets Redundancy and Failover Zero downtime for upgrades and maintaince Master-slave replication –Strong Consistency –Delayed Consistency Geospatial features Host1:10000 Host2:10001 Host3:10002 replica 1 Client

Consistency of data All read operations issued to the primary of a replica set are consistent with the last write operation Reads to a primary have strict consistency Reads reflect the latest changes to the data Reads to a secondary have eventual consistency Updates propagate gradually If clients permit reads from secondary sets – then client may read a previous state of the database Failure occurs before the secondary nodes are updated System identifies when a rollback needs to occur Users are responsible for manually applying rollback changes

Memory Mapped Files A memory-mapped file is a segment of virtual memory which has been assigned a direct byte-for-byte correlation with some portion of a file or file-like resource. mmap()

18 Sharding Partition your data Scale write throughput Increase capacity Auto-balancing Host1:10000Host2:10010 Host3:20000 shard 1 shard 2 Host4:30000 configdb Client

Choices made for Design of MongoDB Scale horizontally over commodity hardware Lots of relatively inexpensive servers Keep the functionality that works well in RDBMSs – Ad hoc queries – Fully featured indexes – Secondary indexes 19

Column store 20

Row Store and Column Store In row store data are stored in the disk tuple by tuple. Where in column store data are stored in the disk column by column 21

Row Store and Column Store Most of the queries does not process all the attributes of a particular relation. For example the query Select c.name and c.address From CUSTOMES as c Where c.region=Mumbai; Only process three attributes of the relation CUSTOMER. But the customer relation can have more than three attributes. Column-stores are more I/O efficient for read-only queries as they read, only those attributes which are accessed by a query. 22

Row Store and Column Store So column stores are suitable for read-mostly, read-intensive, large data repositories Row StoreColumn Store (+) Easy to add/modify a record(+) Only need to read in relevant data (-) Might read in unnecessary data(-) Tuple writes require multiple accesses 23

Why Column Stores? Can be significantly faster than row stores for some applications –Fetch only required columns for a query –Better cache effects –Better compression (similar attribute values within a column) But can be slower for other applications –OLTP with many row inserts,.. Long war between the column store and row store camps :-) 24

Column Stores - Data Model Standard relational logical data model –EMP(name, age, salary, dept) –DEPT(dname, floor) Table – collection of projections Projection – set of columns Horizontally partitioned into segments with segment identifier 25

Column Stores - Data Model To answer queries, projections are joined using Storage keys and join indexes Storage Keys: –Within a segment, every data value of every column is associated with a unique Skey –Values from different columns with matching Skey belong to the same logical row 26

Column Stores – Data Model Join Indexes –T1 and T2 are projections on T –M segments in T1 and N segments in T2 –Join Index from T1 to T2 is a table of the form: (s: Segment ID in T2, k: Storage key in Segment s) Each row in join index matches corresponding row in T1 –Join indexes are built such that T could be efficiently reconstructed from T1 and T2 27

Column Stores – Data Model Construct EMP(name, age, salary) from EMP1 and EMP3 using join index on EMP3 28

Compression Trades I/O for CPU –Increased column-store opportunities: –Higher data value locality in column stores –Data compression techniques such as run length encoding far more useful Schemes –Null Suppression –Dictionary encoding –Run Length encoding –Bit-Vector encoding –Heavyweight schemes 29

Query Execution - Operators Select: Same as relational algebra, but produces a bit string Project: Same as relational algebra Join: Joins projections according to predicates Aggregation: SQL like aggregates Sort: Sort all columns of a projection 30

Query Execution - Operators Decompress: Converts compressed column to uncompressed representation Mask(Bitstring B, Projection Cs) => emit only those values whose corresponding bits are 1 Concat: Combines one or more projections sorted in the same order into a single projection Permute: Permutes a projection according to the ordering defined by a join index Bitstring operators: Band – Bitwise AND, Bor – Bitwise OR, Bnot – complement 31

Row Store Vs Column Store the difference in storage layout leads to that one can obtain the performance benefits of a column-store using a row-store by making some changes to the physical structure of the row store. This changes can be –Vertically partitioning –Using index-only plans –Using materialized views 32

Vertical Partitioning Process: –Full Vertical partitioning of each relation Each column =1 Physical table This can be achieved by adding integer position column to every table Adding integer position is better than adding primary key –Join on Position for multi column fetch Problems: –“Position” - Space and disk bandwidth –Header for every tuple – further space wastage e.g. 24 byte overhead in PostgreSQL 33

Vertical Partitioning: Example 34

Index-only plans Process: –Add B+Tree index for every Table.column –Plans never access the actual tuples on disk –Headers are not stored, so per tuple overhead is less Problem: –Separate indices may require full index scan, which is slower –Eg: SELECT AVG(salary) FROM emp WHERE age > 40 –Composite index with (age, salary) key helps. 35

Index-only plans: Example 36

Materialized Views Process: –Create ‘optimal' set of MVs for given query workload –Objective: Provide just the required data Avoid overheads Performs better Expected to perform better than other two approach Problems: –Practical only in limited situation –Require knowledge of query workloads in advance 37

Materialized Views: Example 38 Select F.custID from Facts as F where F.price>20

Optimizing Column oriented Execution Different optimization for column oriented database –Compression –Late Materialization –Block Iteration 39

Compression Low information entropy (high data value locality) leads to High compression ratio Advantage –Disk Space is saved –Less I/O –CPU cost decrease if we can perform operation without decompressing Light weight compression schemes do better 40

Compression If data is sorted on one column that column will be super- compressible in row store eg. Run length encoding 41

Late Materialization Most query results entity-at-a-time not column-at-a-time So at some point of time multiple column must be combined One simple approach is to join the columns relevant for a particular query But further performance can be improve using late-materialization  Idea: Delay Tuple Construction  Might avoid constructing it altogether  Intermediate position lists might need to be constructed  Eg: SELECT R.a FROM R WHERE R.c = 5 AND R.b = 10  Output of each predicate is a bit string  Perform Bitwise AND  Use final position list to extract R.a 42

Late Materialization Advantages –Unnecessary construction of tuple is avoided –Direct operation on compressed data –Cache performance is improved 43

Block Iteration Operators operate on blocks of tuples at once Iterate over blocks rather than tuples Like batch processing If column is fixed width, it can be operated as an array Minimizes per-tuple overhead Exploits potential for parallelism Can be applied even in Row stores – IBM DB2 implements it 44

Graph databases 45

What is a Graph Database? A database with an explicit graph structure Each node knows its adjacent nodes As the number of nodes increases, the cost of a local step (or hop) remains the same Plus an Index for lookups Express Queries as Traversals. Fast deep traversal instead of slow SQL queries that span many table joins. Very natural to express graph related problem with traversals (recommendation engine, find shortest parth etc..) Seamless integration with various existing programming languages. ACID Transaction with rollbacks support. Distinguish between “Database for graph as object”!

Social Network “path exists” Performance Experiment: ~1k persons Average 50 friends per person pathExists(a,b) limited to depth 4 # persons query time Relational database ms Neo4j10002ms Neo4j ms

Compared to Relational Databases Optimized for aggregation Optimized for connections

Compared to Key Value Stores Optimized for simple look-ups Optimized for traversing connected data

Compared to Document Stores Optimized for “trees” of data Optimized for seeing the forest and the trees, and the branches, and the trunks

Property Graph

What is Neo4j? A Graph Database + Lucene Index Property Graph Full ACID (atomicity, consistency, isolation, durability) (?) High Availability (with Enterprise Edition) 32 Billion Nodes, 32 Billion Relationships, 64 Billion Properties Embedded Server REST API

Good For Highly connected data (social networks) Recommendations (e-commerce) Path Finding (how do I know you?) A* (Least Cost path) Data First Schema (bottom-up, but you still need to design)

Summary: noSQL Common Advantages Cheap, easy to implement (open source) Data are replicated to multiple nodes (therefore identical and fault-tolerant) and can be partitioned –Down nodes easily replaced –No single point of failure Easy to distribute Don't require a schema Can scale up and down Relax the data consistency requirement (CAP)

Summary: What are we giving up? joins group by order by ACID transactions (none are strict ACID!) SQL as a sometimes frustrating but still powerful query language easy integration with other applications that support SQL

QSX (LN2)56

57

Invisible Join Phase 3 58

Invisible Join Between-Predicate rewriting –Use of range predicates instead of hash lookup in phase 1 –Useful if contiguous set of keys are valid after applying a predicate –Dictionary encoding for key reassignment if not contiguous –Query optimizer is not altered. Predicate is rewritten at runtime 59