Skip to main content
No. of Recommendations: 28
Hi jwiest,

Thanks for your thoughts on MongoDB. I agree with you that both relational and NoSQL DBs have their pros and cons. I hope this thread doesn't devolve into a pure tech debate, since that's not the primary purpose of this board. Also, if you have SQL skills, don't worry, they'll continue to be valuable.

Anyway, I have direct experience with trying to add a column to a production MySQL database with 8 million rows in the middle of a busy business day. It was not a fun experience. Queries got locked out, and caused a temporary outage for our users.

That's because in MySQL 8, the ALTER TABLE ... ADD COLUMN command does lock the table, as documented in this article:

So, whenever we needed to update our schema, especially on that big a table, we would schedule it in the dead of night, as part of scheduled maintenance.

As for your comments about defining a schema in advance, let me quote directly from the Mongo docs:

Flexible Schema
"Unlike SQL databases, where you must determine and declare a table’s schema before inserting data, MongoDB’s collections, by default, does not require its documents to have the same schema. That is:

* The documents in a single collection do not need to have the same set of fields and the data type for a field can differ across documents within a collection.

* To change the structure of the documents in a collection, such as add new fields, remove existing fields, or change the field values to a new type, update the documents to the new structure.

* This flexibility facilitates the mapping of documents to an entity or an object. Each document can match the data fields of the represented entity, even if the document has substantial variation from other documents in the collection."

And, yes, you still do need to define indexes in MongoDB to make searching fast. My point is that you can start with a minimum number of required fields, and an index, and then each collection can have an additional number of variable fields, as your business needs evolve.

There are actually at least two types of NoSQL databases. One type is a key/value store, like Cassandra (the database used by Facebook) or Amazon's DynamoDB. The other type is document-oriented NoSQL DB like MongoDB. The advantage with the latter is that you can search for elements even within deeply nested JSON structues. Note that a "document" here is not a PDF - it refers to a data format called JSON which is used to represent fields within data, including nested fields.

I hope this clears things up.
Print the post  


What was Your Dumbest Investment?
Share it with us -- and learn from others' stories of flubs.
When Life Gives You Lemons
We all have had hardships and made poor decisions. The important thing is how we respond and grow. Read the story of a Fool who started from nothing, and looks to gain everything.
Contact Us
Contact Customer Service and other Fool departments here.
Work for Fools?
Winner of the Washingtonian great places to work, and Glassdoor #1 Company to Work For 2015! Have access to all of TMF's online and email products for FREE, and be paid for your contributions to TMF! Click the link and start your Fool career.