NMD 445: Mobile Applications

NoSQL data structures

Nosql Icon

SQL versus NoSQL

Feature
SQL
NoSQL
Languages
PHP/SQL
JavaScript/JSON
Layout
Tables
Trees
Unit
Records
Nodes
Relationships
Explicit
Implicit

Strengths

SQL strengths

Complex data structures (archives, museums, libraries)

Used by Wikipedia, NASA

Easy to visualize

NoSQL strengths

No extra languages to learn

Real-time

Quick transactions (social media/game)

Used by Facebook, Twitter, Netflix, Amazon

Portable (just JSON)

Adjustable on the fly

Scalable

Your data as a JSON object


	petFinderObject = {
		"pets": {
			"-petId1": {
			    "petName": "Grumpy Cat",
				"petImage": "https://...",
				"petLink": "https://..."
			},
			"-petId2": {
				"petName": "Nyan Cat",
				"petImage": "https://...",
				"petLink": "https://..."
			}
		},
		"users": {
			"-userId1": {
				"userName": "Mary",
				"userEmail": "mary@gmail.com",
				"userImage": "https://..."
			},
			"-userId2": {
				"userName": "Sarah",
				"userEmail": "sarah@gmail.com",
				"userImage": "https://..."
			}
		}
	} ;

Your data as a NoSQL tree

All the nodes at https://petfinder.com


	pet-finder
		|_ pets
			-petId1
			    |_ petName: "Grumpy Cat"
				|_ petImage: "https://..."
				|_ petLink: "https://..."
			-petId2
				|_ petName: "Nyan Cat"
				|_ petImage: "https://...",
				|_ petLink: "https://..."
		|_ users
			-userId1
				|_ userName: "Mary"
				|_ userEmail: "mary@gmail.com"
				|_ userImage: "https://..."
			-userId2
				|_ userName: "Sarah"
				|_ userEmail: "sarah@gmail.com"
				|_ userImage: "https://..."

Each node corresponds to a URL

Return all the nodes at https://petfinder.com/pets


{
	"-petId1": {
	    "petName": "Grumpy Cat",
		"petImage": "https://...",
		"petLink": "https://..."
	},
	"-petId2": {
		"petName": "Nyan Cat",
		"petImage": "https://...",
		"petLink": "https://..."
	}
}

Each node corresponds to a URL

Return all the nodes at https://petfinder.com/users


{
	"-userId1": {
		"userName": "Mary",
		"userEmail": "mary@gmail.com",
		"userImage": "https://..."
	},
	"-userId2": {
		"userName": "Sarah",
		"userEmail": "sarah@gmail.com",
		"userImage": "https://..."
	}
}

Each node corresponds to a URL

Return the first user's name with https://petfinder.com/users/-userId1/userName


	"Mary"

/