Why are relational databases unsuitable for unstructured data?
database, nosql, relational-database, sql
Solution
My favorite example of unstructured data which is not a good fit for a relational database is the computer hardware parts database.
Imagine you have a web shop which sells computer hardware. How would your product database look?
Every product has a `name`, a `price` and a `vendor`. But CPUs have a `clock rate`, a `cache size` and a `# of cores`, monitors have a `size` and `resolution`, RAM modules have a `capacity` and hard drives have also a `capacity` (which can not be compared to that of RAM modules).
How would you store this data in a relational database?
- You could create a very wide table with hundreds of field for any possible attribute some product could have, but for most product most of these fields will be NULL.
- You could have a separate table for each product category
- You could have a huge table with the columns `product`, `property` and `value` which maps all the properties to the values (but what type do you use for `value` when some properties are numeric and others aren't?)
All three options are valid, but none of them is really satisfying.
But when you have a document-oriented database without a strict schema, it becomes a lot simpler because each entry can have any set of attributes which can have values of any type.
Problem
I've been researching NoSQL databases, and a common theme that comes up is that relational databases are unsuitable for storing unstructured data. For example: Unfortunately, the rigidly defined, schema-based approach used by relational databases... is a poor fit for unstructured and semi-structured data [source] I'm having a hard time understanding why this is. For example, if I wanted to store an image or some raw text in a relational database, could I not just store it as a text type (e.g. in a single column table or a key-value table)?