CIS4610- quiz 5

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

MongoDB

(derived from the word humongous) is a document database, a relatively new breed of database that has no concept of tables, schemas, SQL, or rows. Therefore, it does not have foreign keys, ACID compliance, or joins.

ACID Properties RDB

-Atomicity: The update is invisible. ALL parts of it must be complete or the database must be left in the state it was in before the transaction started -Consistency: At the conclusion of the transaction, the database must be in a physically and logically consistent state. In other words, the data must accurately reflect any changes up to a certain point in time -Isolation: Two concurrently executing transactions must result in the same database state that would have existed if they had executed one after the other. -Durability: After a transaction has completed, its effects cannot be lost even if there is a system software or hardware failure. That is, there is no undo button.

BASE Properties NoSQL

-Basically Available: This constraint states that the system does guarantee the availability of the data. There is a response to every query. But, that response could still be 'failure' to obtain the requested data or the data may be in an inconsistent or changing state -Soft-state: Soft-state means that the NoSQL database plays 'catch up' updating the database continuously even with changes that occurred earlier in the day -Eventual consistency: 'Consistent' means that the data accurately reflects any changes up to a certain point in time.

MongoDB properties

-Document-oriented: Unlike RDB that takes a business subject and breaks it up into multiple relational structures, MongoDB stores the business subject in the minimal number of documents. -Extremely extensible: Capable of representing complex hierarchical relationships in one place (document). -Horizontally Scalable: Scale out capability. Documents are easy to partition across multiple servers. MongoDB can automatically balance data across servers and redistribute documents, automatically routing user requests to the correct machine. -Drivers: MongoDB has set of drivers based on functions such as find(), update().

Attribute/Field

-MongoDB field contains two parts, a field name and a field value.

MongoDB answers these questions;

-What questions do i have -what data can i use -n-dimensional attributes -query an field at any level -highly flexible schema

During logical data modeling, questions or issues may arise having to do with specific hardware or software such as:

-What should the collection Look like? -What is the optimal way to do sharding? -How can we make this information secure? -How should we store history? -How can we answer a business question quickly.

JSON object

-a key-value data format that is typically rendered in curly braces -could be many lines long

ObjectId

-•Every MongoDB document is identified by a unique _idfield. Although the _id defaults to an ObjectId type, another data type may also be used as long as it is unique within a collection. -You may have Collection User01 contain a document with an _id key of 12345 and Collection User02 with an _id key of 12345, but collection User01 cannot contain two documents with the _id key 12345.

logical data modeling steps;

1. fill in the CDM 2. normalize and abstract (relational only) 3. determine the most useful form 4. review and confirm

Five steps to CDM:

1.Ask five strategic questions 2.Identify and define concepts 3.Capture the relationships 4.Determine the most useful form 5.Review and confirm

Five steps to physical data modeling in MongoDB:

1.Embed or Reference 2.Accommodate History 3.Index and Shard 4.Review and confirm 5.Implement

(CDM) Five strategic questions:

1.What is the application for? 2."As is" or "to be"? 3.Is analytics a requirement? 4.Who is the audience (validator and user)? 5.Flexibility or simplicity?

number

64-bit floating points numbers

non-identifying relationship

A relationship in which the primary key of the related entity does not contain a primary key component of the parent entity.

Documents are flexible

Documents in the same policy collection in MongoDB (do not follow a standard structure)

Three main types of domains in RDB

Format, List, and Range

(CDM) Identify and define concepts:

Is the database for an operational or reporting system? Do we need to take relational or dimensional approach or both? 1.Mostly transactional system - Which approach? 2.Mostly Operational system - Which approach? 3.Mostly Reporting system - Which approach? 4.Analyze and play with numbers - Which approach?

advantages to MongoDB

It lets us add components in the document we might have forgotten or not known about earlier.

MongoDB uses

JavaScript as the main query language.

File storage:

MongoDB can be used as a file system, called Grid File System (GridFS), with load balancing and data replication features over multiple machines for storing files.

Like Relational Databases

MongoDB supports queries, indexing, and real time aggregation for accessing and analyzing data

Rollup:

Rollup means rolling up the subtypes up into the supertype. The subtypes disappear, and all attributes and relationships only exist at the supertype level.

Reference

The concept of a foreign key in relational database is similar to the concept of a reference in MongoDB. Both a foreign key and a reference provide a way to navigate to another structure. Difference: 1.RDB: automatically ensures each foreign key value also exist as a value in the originating PK with referential integrity. 2.MongoDB: the reference is simply a way to navigate to another structure without the referential integrity.

domains

The set of all possible values that an attribute contains -. An attribute can never contain values outside of its assigned domain which is defined by specifying the actual list of values or a set of rules

the biggest difference between XML and JSON is

XML has to be pared with an XML Parker. JSON can be parsed by a standard JavaScript function

JSON (JavaScript Object Notation)

a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages

Sharding

a method for distributing data across multiple machines. MongoDB uses sharding to support deployments with very large data sets and high throughput operations.

a collection is

a set of one or more documents.

An entity at the physical level is

a table in an RDBMS or a collection in MongoDB.

Identity:

all of the business rules at the supertype level and at the subtype level remain the same as in the logical data model. That is, we can continue to enforce relationships at the supertype or subtype levels as well as enforce that certain fields be required at the supertype or subtype levels

embedded data models

allow applications to store related pieces of info. in the same DB record

string

any string of unicode transformation format-8 (UTF-8) characters

Both JSON and XML

are "self describing" are hierarchical can be parsed and used by lots of programming languages can be fetched with an XMLHttpRequest

array

can be ordered or unordered -can contain different data types as values and even other arrays

globally unique id

can be used as the PK value for records and documents

date

captured as milliseconds

•Dropping a single Index:

db.collection.dropIndex("cust_name");

•Code for dropping all indexes:

db.customer.dropIndex("*")

Delete All Documents

db.inventory.deleteMany({})

find function

db.products.find( { item: "card" } )

display collections documents

db.restaurants.find().pretty()

Create unique Index

db.students.ensureIndex( { WIN : 1 }, { "unique" : true } ) -1 indicates that WIN will be indexed in ascending order (as opposed to -1, which means descending order). true means that WIN must be unique. For a non-unique index, the value must be 'false'

JSON is not like XML because JSON

doesn't use end tag is shorter is quicker to read and write can use arary

MongoDB stores its data in

flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time.

MongoDB being a distributed database means

high availability, horizontal scaling, and geographic distribution are built in and easy to use

Identifying

is a much stronger relationship than non-identifying relationship, giving more weight towards embedding the weak entity within the strong entity so that we have just one document.

Rolldown:

means we are moving the attributes and relationships of the supertype down to each of the subtypes. Produces more user friendly structure.

boolean

only the values of 1 (true) and 0 (false)

showdbs

show all databases

show collections

show collections in desired DB

Physical Data Modeling (PDM)

the process of capturing the detailed technical solution

Conceptual data Modeling (CDM)

the process of capturing the satellite view of the business requirements

use Restaurants

use Restaurants DB

NoSQL vs RDBMS

variety: RDBMS one type (relational), NoSQL four main types:document column oriented key value and graph structure: RDBMS predefined, NoSQL dynamic scaling: RDBMS primarily vertical, NoSQL primarily horizontal focus: RDBMS data integrity, NoSQL data performance and availability

Alternate key

•Alternate Key (AK) in MongoDB is equivalent to the composite key in relational database.

restrictions to naming fields in MongoDB

•Avoid special characters (period, $, {, @,#, .........) •MongoDB is case sensitive, for example, CustomerLastName and customerLastname are distinct fields. •Duplicate names are not allowed. The same document cannot contain two or more of the same field at the same level of depth. A document can, however, have the same field name at a different level of depth.

Indexing:

•Fields in a MongoDB document can be indexed with primary and secondary indices.

Server-side JavaScript execution:

•JavaScript can be used in queries, aggregation functions (such as MapReduce), and sent directly to the database to be executed.

Logical data modeling (LDM)

•Logical data modeling is the process of capturing the detailed business solution. •Logical data model looks the same regardless of implementation of relational (SQL Server) or non-relational (MongoDB) database.

Replication:

•MongoDB provides high availability with replica sets. A replica set consists of two or more copies of the data.

Aggregation:

•MongoDB provides three ways to perform aggregation: the aggregation pipeline, the map-reduce function, and single-purpose aggregation methods.

Load balancing:

•MongoDB scales horizontally using sharding. The user chooses a shard key, which determines how the data in a collection will be distributed.

Ad-hoc queries:

•MongoDB supports field, range query, and regular-expression searches.

Deleting Collection in MongoDB with drop function

•db.collection.drop()

insert function

•db.collection.insert({document})

Deleting Data in MongoDB with remove function

•db.collection.remove({criteria}, {justOne})

Updating Data in MongoDB with update function

•db.collection.update({criteria}, {changes}, {upsert, multi } )

insertMany Command

•db.inventory.insertMany( [ • { item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" }, • { item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "P" }, • { item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" }, • { item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" }, • { item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" }, •] );


Ensembles d'études connexes

Grammar: Verb Forms - Gerunds, Participles, and Infinitives

View Set

Module 6 - Medicare Supplement Policies (Medigap)

View Set

PrepU Chapter 29: Heart Disease (Exam 1)

View Set

Business Ethics Classes 7-9 (Ch. 4, 8, 9)

View Set

Phylum Porifera, Bryozoa, Hemichordata, Cnidaria, Phylum Arthropoda Genus.

View Set