We've got to maintain a certain level of 'street-cred'.

MySQL vs. MongoDB

Want an open source database? There are several to choose from, and two of those are MySQL and MongoDB. How do you make the decision which to use? You choose the one that has the most of what you need.

Both MySQL and MongoDB are open source databases, meaning they are free to download and use.

How are they the same?

  • Both are databases.
  • Both use indexes to optimize queries.
  • Both can be used to aggregate data.

How are they different?

  • MySQL uses tables and MongoDB uses collection (a collection does not enforce a schema and can exist within a single database with different fields).
  • MySQL uses rows in the table to represent terms and MongoDB uses the document to represent terms.
  • In MySQL, the primary key can be specified as any unique column or combination of columns, while in MongoDB, the primary key is automatically set to the _id field.
  • MySQL can do data joins while MongoDB would use two queries to do a join.
  • MySQL uses a string to conduct a query while MongoDB uses objects for a query.
  • With MySQL, you define the tables and columns in the beginning before data entry, while with MongoDB you define the schema when you need to run a query.
  • In MySQL, the data is structured while in MongoDB the structure is flexible.

So, how to choose? If your data is structured and fits into a table, then you might want to consider MySQL. If your data is not table structured, then consider MongoDB.

Still not sure which is best for you? Then just contact us and let's have that conversation.