How to organise a many to many relationship in MongoDB

What I’ve seen done, and what I currently use are embedded arrays with node id’s in each document. So document user1 has property groups: [id1,id2] And document group1 has property users: [user1]. Document group2 also has property users: [user1]. This way you get a Group object and easily select all related users, and the same … Read more

Are relational databases a poor fit for Node.js?

No, there isn’t a technical reason. It’s mostly just opinion and using NoSQL with Node.js is currently a popular choice. Granted, Node’s ecosystem is largely community-driven. Everything beyond Node’s core API requires community involvement. And, certainly, people will be more likely to support what aligns with their personal preferences. But, many still use and support … Read more

Practical example for each type of database (real cases) [closed]

I found two impressive articles about this subject. All credits to highscalability.com. The information in this answer is transcribed from these articles: 35+ Use Cases For Choosing Your Next NoSQL Database What The Heck Are You Actually Using NoSQL For? If Your Application Needs… • complex transactions because you can’t afford to lose data or … Read more

When shouldn’t you use a relational database? [closed]

In my experience, you shouldn’t use a relational database when any one of these criteria are true: your data is structured as a hierarchy or a graph (network) of arbitrary depth, the typical access pattern emphasizes reading over writing, or there’s no requirement for ad-hoc queries. Deep hierarchies and graphs do not translate well to … Read more

Pros/cons of document-based databases vs. relational databases

You need to think of how you approach the application in a document oriented way. If you simply try to replicate how you would model the problem in an RDBMS then you will fail. There are also different trade-offs that you might want to make. ([ed: not sure how this ties into the argument but:] … Read more

Still Confused About Identifying vs. Non-Identifying Relationships

The technical definition of an identifying relationship is that a child’s foreign key is part of its primary key. CREATE TABLE AuthoredBook ( author_id INT NOT NULL, book_id INT NOT NULL, PRIMARY KEY (author_id, book_id), FOREIGN KEY (author_id) REFERENCES Authors(author_id), FOREIGN KEY (book_id) REFERENCES Books(book_id) ); See? book_id is a foreign key, but it’s also … Read more

What is the difference between a Relational and Non-Relational Database?

Hmm, not quite sure what your question is. In the title you ask about Databases (DB), whereas in the body of your text you ask about Database Management Systems (DBMS). The two are completely different and require different answers. A DBMS is a tool that allows you to access a DB. Other than the data … Read more

Modeling Product Variants

You could have a design like: +—————+ +——————-+ | PRODUCTS |—–< PRODUCT_VARIANTS | +—————+ +——————-+ | #product_id | | #product_id | | product_name | | #variant_id | +—————+ | sku_id | | +——————-+ | | +——–^——–+ +——–^——–+ | PRODUCT_OPTIONS |—–< VARIANT_VALUES | +—————–+ +—————–+ | #product_id | | #product_id | | #option_id | | #variant_id … Read more

How do you like your primary keys? [closed]

If you’re going to be doing any syncing between databases with occasionally connected apps, then you should be using GUIDs for your primary keys. It is kind of a pain for debugging, so apart from that case I tend to stick to ints that autoincrement. Autoincrement ints should be your default, and not using them … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)