4 ms·
"I don't want to create a schema..." You are always going to end up creating a schema, whether it's explicit in your tables or implicit within your code. Other
by ris 12y ago
"I don't want to create a schema..."
You are always going to end up creating a schema, whether it's explicit in your tables or implicit within your code. Otherwise you end up with completely heterogeneous data which is impossible to query in any useful way.
This is a red herring.
- woah 12y agoNot really. Maybe some products have an attribute that others don't. Maybe you want to query by that attribute. The query won't turn up products without that attribute. Maybe that's ok. Like if you wanted to find all shoes with black laces you can just query for that. Tractors don't even have laces and so they don't come up in the results. In a sql db, every single thing needs to fit into a flat schema with nesting done by relations. Additionally, it's very rigid. Maybe you just don't want to set up a laces table, and 4000 other tables for every little attribute of every product. Of course this is not how you would do it in real life, there are better ways. Mongo is one of those ways. Saying that Mongo is good for nothing is just as dumb as saying that Mongo is good for everything. In 2015, the Mongo backlash is just as tired as the Mongo hype.
- annnnd 12y agoAgreed. That said, optional schema enforcement would be really nice (in my experience, most of the data has a predefined format; so why not define schema and enforce it?).
- gasping 12y agoAre you saying you're using a single MongoDB collection as a dumping ground for all your entities? I hope you're not building a real product that someone has to maintain.
- woah 12y agoI don't actually use Mongo at all, I prefer Postgres. But for loosely structured data, it has a use case. Just like dynamic vs typed languages, there are pros and cons.
- icebraining 12y agoIn a sql db, every single thing needs to fit into a flat schema with nesting done by relations. Nope, see Postgres (hstore and json).
- mgkimsal 12y agowhy not "see sql server from 10 years ago with xml column type"?
- icebraining 12y agoBecause one example is enough to dispel that myth, and I'm familiar with Postgres, and not with "sql server from 10 years ago with xml column type".
- xerophyte12932 12y agoI would probably solve this problem using Relational DB by having an ItemHeader table with all the common attributes. Then will make an ItemAttributes table where I'd use the foreign key of the first table and just have Key/value pairs for all the unique attributes you want to give to the item. Any sort of query on any of the attributes can be one via a simple join. Though i suppose it gets trickier if attributes may have sub attributes etc....
- ris 12y ago"In 2015, the Mongo backlash is just as tired as the Mongo hype." If you say so.