[17:27:47] <robertparkerx> I don't know much about Mongo but I'm upgrading a environment. I upgraded ubuntu, PHP, MySQL and I had to install MongoDB because what the environment was using has been depcrated.
[18:55:08] <robertparkerx> Can someone help me with this error? https://pastebin.com/MB143KWm
[19:05:22] <GothAlice> AJTJ: Multiple $group stages can be used, each producing their own count. Or you can generate multiple counted fields within one $group stage.
[19:08:26] <GothAlice> AJTJ: For example, in invoice type models, I often aggregate on invoices, unwind on line items, match those items, then $group using a count(1), count(line item.quantity) and sum(line item.quantity * line item.price), as one example of generating multiple result fields at once.
[19:14:48] <GothAlice> Where those count() are actually sum(). XP
[20:04:19] <bbear> can someone tell me, what are the benefits and advantages of MongoDB vs MySQL
[20:06:47] <GothAlice> bbear: https://grimoire.ca/mysql/choose-something-else — MongoDB does not suffer virtually any of these problems.
[20:07:29] <GothAlice> However, note, MongoDB only really supports "LEFT OUTER JOIN" "relational" models, and only when queried in a particular way which may be limiting. For relational data, I recommend PostgreSQL; it's good people for relational data.
[20:09:51] <GothAlice> And yes, MongoDB does have schemas, called "validation documents", a form of saved query/filter that must match which can enforce all the things schemas normally do, and more. :)
[20:11:32] <bbear> Let me know if the image I have in mind is false. In MySQL, when you define an object, it can has relations with multiple tables, thus making aggregation a gruesome job with operators like LEFT JOIN / INNER JOIN / and so on. In Mongodob, nothing of the kind. You just store your data "as it", there's no schema. You can still have indexes for some documents on some primary field.
[20:12:22] <bbear> but there is no primary key concept, meaning you can store the two exact same document in a mongo DB, and it's up to you then to know what exactly to do with this data.
[20:12:43] <bbear> in short, referential integrity is not used in mongo.
[20:12:57] <robertparkerx> I'm stuck on a error for Mongo. The extension changed and some stuff was removed completely in newer version. I was able to fix some of the error but not all. The next error that popped up was : https://pastebin.com/MB143KWm
[20:13:24] <GothAlice> bbear: "there's no schema" → False. There is, if you want it: https://docs.mongodb.com/manual/core/schema-validation/ (optional)
[20:14:27] <GothAlice> "there is no primary key concept" → False. MongoDB supports rich indexing, and has a default primary key index on a field named "_id", which client drivers will auto-populate with a new ObjectID if missing during insert. https://docs.mongodb.com/manual/indexes/index.html
[20:16:25] <GothAlice> True, there is no referential integrity checking. During querying, in the form of an "aggregate query", you can $lookup, which is equivalent to a LEFT OUTER join, but that's only the most common join case in existence. (I.e. a record references another, and you need a field from that other while querying the first.)
[20:20:32] <bbear> GothAlice, is this a cross(document/table) lookup ?
[20:20:42] <bbear> so a basic left join to rule them all IIRC
[20:20:49] <bbear> I mean if i understand correctly
[20:21:17] <GothAlice> It's a fetch of a document, usually from a foreign collection, but can be same-collection, there's no restriction on that. (I.e. for parent lookups in hierarchies.)
[20:21:25] <bbear> but that's not basically what you would do, I mean, why not just copy the whole part you need instead of doing left joins ?
[20:21:44] <bbear> I mean it's not really in the mongo philosophy, isn't it ?
[20:22:00] <bbear> but ok, it exists, if I understand you correctly.
[20:22:23] <bbear> I mean left join can be expensive in MySQL so you avoid doing too many of them.
[20:22:29] <GothAlice> There remain certain uses for relational-style references stored within documents. One can either store the _id of the foreign document and implement in code what that actually points to, or you can use a DBRef, which also encodes the name of the collection.
[20:26:15] <bbear> I would like to know basically why no-sql database came so lately over relation databases.
[20:26:21] <GothAlice> The sharding key is used to distribute the documents amongst the nodes in the shard set; the query router your application connects to then uses that to identify where to query, if possible to optimize.
[20:27:22] <GothAlice> https://docs.mongodb.com/manual/sharding/ (re: above, with note to Shard Keys and Sharding Strategy sections)
[20:28:31] <GothAlice> In my case I needed to evenly distribute data across the nodes, more than anything else. I was using it as a storage load distribution mechanism. ('Cause that's a lot of data, yo. ;)
[20:29:49] <robertparkerx> GothAlice, could you help me understand something?
[20:30:27] <robertparkerx> I'm stuck on a error for Mongo. The extension changed and some stuff was removed completely in newer version. I was able to fix some of the error but not all. The next error that popped up was ^]
[20:30:59] <GothAlice> ("Earwax." -- Dumbledore) Can't see anything on that site, restricted access due to known malware use.
[20:32:18] <bbear> I can envision that there's not a good load of good mongoDB engineers/admin around there.
[20:32:54] <bbear> @robertparkerx, seems to me like a PHP error, not a mongo error.
[20:33:41] <GothAlice> Have deployed it a number of times, in different configurations, with enough understanding to be able to automate the process if needed, yourself. To understand the mechanisms of operation of MongoDB (i.e. memory mapped files) and the requisite awareness of server oriented UNIX use (i.e. re: THP, memory paging / swap, firewalling). If back-end.
[20:34:59] <GothAlice> If as a user, i.e. application developer or database admin, all of the database admin tools it comes bundled with and the appropriate scenarios for use of each, and modelling concepts. (I.e. how to properly implement localization, or documents with dynamic attributes.)
[20:36:00] <GothAlice> robertparkerx: Indeed, I can't assist with PHP. That error looks very strange, though.
[20:36:13] <GothAlice> Must be an instance of MongoDB, the namespace?
[20:39:46] <bbear> "implement localization, or documents with dynamic attributes" <- it exists ?
[20:40:22] <bbear> Well, I am starting to think that if mongoDB doesn't hit massive adoption yet, it is mainly because of inertia.
[20:40:44] <GothAlice> I've used it on every project for the last 9 or so years.
[20:41:01] <GothAlice> So, adoption over here is 100%. XP
[20:41:19] <bbear> What do you think ? It seems massively more flexible and scalable.
[20:41:37] <bbear> in which specific case would you prefer a relational DB ?
[20:42:01] <bbear> GothAlice, ok, from what I infer you would answer, none.
[20:42:05] <GothAlice> A classic story I give is that of joining a project two weeks into planning and replacing, I kid you not, Postgres + Redis + membase + zeromq + rabbitmq + elasticsearch with… just MongoDB.
[20:43:14] <GothAlice> Now that MongoDB has had proper Decimal fields for a while, and transactions since 4.0, I have no personal use for a highly relational database. I don't think about data as if it were all a spreadsheet, any more.
[20:44:30] <bbear> only drawback if you allow me to be extra-cautious and nit-picking, is that mongoDB moves fast, and so the technology is not as mature as you would like it to be.
[20:44:33] <GothAlice> It can be so much more awesome than that. A collection of forum discussion threads, where the replies (all comments / whatever) are embedded within the thread document. Makes retrieval of a thread for display (or a subset of it, e.g. page of comments) a single primary key lookup.
[20:45:14] <GothAlice> Then there's this: https://github.com/marrow/mongo/pull/11/commits/a7a02106ec4181d07d1d772a216b1a5d6d47e1ef#diff-4745b5c62d4d0d557c8ccdcde5af16e5R153 :3
[20:45:32] <GothAlice> (Practical example there from the forums example I use.)
[20:55:22] <bbear> that's a stuff that is basically read 100x times more than it is updated.
[20:58:05] <GothAlice> Much compact. Super minimal. XP
[23:21:34] <robertparkerx> Does the new API havve anything equivalent to $this->collection[$collection] = new MongoCollection(self::$database, $collection);