4. Differences
Relational and NoSQL data models are very
different. The relational model takes data and
separates it into many interrelated tables that
contain rows and columns. Tables reference
each other through foreign keys that are stored
in columns as well.
5. NoSQL databases have a very different model.
For example, a document-oriented NoSQL
database takes the data you want to store and
aggregates it into documents using the JSON
format.
6. types of nosql (currently 150)
1. Wide Column Store / Column Families
2. Document Store
3. Key Value / Tuple Store
4. Graph Databases
5. Multi-Model Databases
...
http://nosql-database.org/
9. So, when to NoSql?
http://kkovacs.eu/cassandra-vs-mongodb-vs-
couchdb-vs-redis
10. Document Databases: Natural data modeling. Programmer friendly. Rapid development. Web
friendly, CRUD, dynamic queries maybe your data changes too much
Graph Databases: Complicated graph problems, graph-style, rich or complex, interconnected
data.
Key-Value Stores: Handles size well. Processing a constant stream of small reads and writes.
Fast, (most use cases: Cache), some times should fit mostly in memory.
BigTable Clones: Handles size well. Stream massive write loads. High availability. Multiple-data
centers. MapReduce.
12. rake db:drop # Drops all the collections for the database
rake db:mongoid:create_indexes # Create the indexes
rake db:mongoid:drop # Drops the default session
rake db:mongoid:purge # Drop all collections except the system collections
rake db:mongoid:remove_indexes # Remove the indexes
rake db:mongoid:remove_undefined_indexes # Remove indexes that exist in the database but
aren't specified on the models
rake db:seed # Load the seed data from db/seeds.rb
13. class Company
include Mongoid::Document
has_many :tickets
end
class Ticket
include Mongoid::Document
embeds_many :categories, as: :categorizable
belongs_to :company
belongs_to :developer
index({ 'categories.name': 1 }, unique: true, sparse: true)
index({ name: 1 }, unique: false)
end
14. class Developer
include Mongoid::Document
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# SCHEMA is in the models, not in schema.rb (No More Migrations)
## Database authenticatable
field :email, type: String
field :encrypted_password, type: String
...
end