NoSQL Database Management Systems PDF
Document Details
Tags
Summary
This document provides an introduction to NoSQL database management systems. It covers Big Data concepts, key-value databases, and column-oriented databases. The document also touches upon basic database operations in a NoSQL context.
Full Transcript
IT2003 Introduction to NoSQL Database Management Systems The key acts as an identifier for the value. The value can be anything such as text, an XML document, or an image....
IT2003 Introduction to NoSQL Database Management Systems The key acts as an identifier for the value. The value can be anything such as text, an XML document, or an image. A. Big Data and NoSQL The database does not attempt to understand the contents of the value Big Data is used to label large volumes of data that push the limits of The database simply stores whatever value is provided for the key. conventional software. This data is usually unstructured or semi- It is the job of the applications that use the data to understand the structured and may originate from a wide variety of sources: social meaning of the data in the value component. media postings, emails, electronic archives with multimedia content, There are no foreign keys. Relationships cannot be tracked among etc. keys at all. Big data generally refers to a set of data that displays the characteristics Greatly simplifies the work that the DBMS must perform, making KV of high-volume, high-velocity, and high-variety (the 3 Vs) information databases extremely fast and scalable for basic processing. assets that demand cost-effective, innovative forms of information Key Value processing for enhanced insight and decision making. 10010 “Lname Banaag Fname Michelle Initial A Phone Volume – the quantity of data to be stored, is a key characteristic of big 09358891234 Balance 0” Table 1. Key-value pair data. The storage capacities associated with big data are extremely large. Column-oriented databases: Velocity – another key characteristic of big data. This refers to the rate can refer to traditional, relational database technologies that use column-centric storage instead of row-centric storage at which new data enters the system as well as the rate at which the More efficient for optimizing read operations to store the data in data must be processed. relational tables, not per row, but per column. Variety – In a big data context, it refers to the vast array of formats and All columns in one row are rarely needed at once, but there are structures in which the data may be captured. groups of columns that are often read together. NoSQL database management systems (NoSQL DBMS) – A new To optimize access, it is useful to structure the data in such groups generation of database management systems that is not based on the of columns—column families—as storage units. traditional relational database model (SQL) which met the two criteria: 1. The data is not stored in tables. (Like SQL) 2. The database language is not SQL. NoSQL is also sometimes interpreted as 'Not only SQL' to express that other technologies (besides relational DBMS) are often used for storing Big Data and in massively distributed web applications. NoSQL technologies are especially necessary if the web service requires high availability (i.e., data in social media like Facebook). NoSQL excels in its ease of use, scalability, resilience, and availability characteristics. Instead of joining tables of normalized data, NoSQL stores unstructured or semi-structured data, often in key-value pairs or JSON documents. B. NoSQL Data Model Key-value (KV) database: It is the simplest of the NoSQL data models. Figure 1. Column-oriented database It stores data as a collection of key-value pairs. 07 Handout 1 *Property of STI [email protected] Page 1 of 4 IT2003 Graph databases: The document can be in any encoded format, such as XML, JSON Graph databases are based on graph theory and represent data (JavaScript Object Notation), or BSON (Binary JSON). through nodes, edges, and properties. Tags are named portions of a document. A node is similar to an instance of an entity in the relational model. Although all documents have tags, not all documents are required Edges are the relationships between nodes. Both nodes and edges to have the same tags, so each document can have its own can have properties, which are attributes that describe the structure. corresponding node or edge. Tags in a document database are extremely important because Graph databases excel at tracking data that are highly interrelated, they are the basis for most of the additional capabilities that such as social media data (Facebook, Instagram, Twitter). document databases have over KV databases. { id: 1, Name: "Justin York", Age: 27, Gender: "Male", Address: { City: "Makati" Country: "Philippines }, Contact: { Mobile: "+639358491124" Email: “[email protected]” } } Example of a Customer document written in JSON format C. Document-Oriented Database MongoDB is a cross-platform, open-source, document-oriented database that provides high performance, high availability, automatic, Figure 2. Graph database and easy scalability. It is highly optimized for JSON. It stores data in flexible JSON documents, which means the columns may vary from Document-Oriented databases document to document, and the data structure may be reformed over Document-oriented databases are conceptually similar to key- time. value databases, and they can almost be considered a subtype of SQL MongoDB KV databases. Database Database A document database is a NoSQL database that stores data in Tables Collections tagged documents in key-value pairs. Unlike a KV database, Columns Fields where the value component can contain any type of data, a Rows Documents document database always stores a document in the value Table 2. SQL vs. MongoDB component. 07 Handout 1 *Property of STI [email protected] Page 2 of 4 IT2003 Database – MongoDB groups collections into databases. A single { instance of MongoDB can host several databases, each of which can "acknowledged" : true, be thought of as completely independent. "insertedIds" : [ Collections – can be thought of as a table with a dynamic schema. ObjectId("5fab4e024d65454f319d8760"), Document – is the basic unit of data for MongoDB, roughly equivalent to a row in a relational database management system (but much more ObjectId("5fab4e024d65454f319d8761") expressive). ] Every document has a special key, "_id", that is unique across the } document's collection. Now if we check the database list using the show dbs command: D. Basic Operations in Document-Oriented Database > show dbs FirstMongoDB 0.000GB If there is no existing database, the given command below will admin 0.000GB automatically create a new database. In MongoDB, you don't need to create a database manually because MongoDB will create it automatically config 0.000GB when you save the value into the defined collection for the first time. db 0.000GB > use FirstMongoDB db_test 0.000GB switched to db FirstMongoDB local 0.000GB nosql 0.000GB > To check the currently selected database, use the db command: > db To query the newly created documents, use this syntax: FirstMongoDB > db.student.find() { "_id" : ObjectId("5fab4e024d65454f319d8760"), To query the database list, use the show dbs command: "name" : "John Smith" } > show dbs { "_id" : ObjectId("5fab4e024d65454f319d8761"), admin 0.000GB "name" : "John Cedrick" } config 0.000GB db 0.000GB To query the database collection lists, use this syntax: db_test 0.000GB > show collections local 0.000GB student nosql 0.000GB Note that after creating a document from the previous query, the student > collection is automatically created. FirstMongoDB is currently not on the list because it does not contain any To manually create a collection in the database, use this syntax: documents. Use this syntax to create a document inside the > db.createCollection("Teacher") FirstMongoDB database. { "ok" : 1 } > db.student.insertMany([ {name: "John Smith"}, {name: "John Cedrick"} ]) 07 Handout 1 *Property of STI [email protected] Page 3 of 4 IT2003 To remove or drop a document in the database, use this syntax: > db.student.remove({name: "John Cedrick"}) WriteResult({ "nRemoved" : 1 }) To remove or drop a collection in the database, use this syntax: > db.student.drop() true To delete the currently selected database, use this syntax: > db.dropDatabase() { "dropped" : "FirstMongoDB", "ok" : 1 } REFERENCES Coronel, C. and Morris, S. (2018). Database systems design, implementation, & management (13th ed.). Cengage Learning. Chodorow, K., Brazil, E., and Bradshaw, S. (2019). MongoDB: The definitive guide (3rd ed.). O'Reilly Media, Inc. 07 Handout 1 *Property of STI [email protected] Page 4 of 4