I’m using mongodb at present but i’ve also been accustomed to MySQL.
I’m trying to ponder can we have a dual field index?
For instance imagine this table:
Firstname | LastName
============+=================
Bob | Bob
Bob | B
John | Bob
A index where we can have the database enforce uniqueness with both the First Name and Last Name as one (wihout having to have an overhead as a third field as both combined or as a hash or something
so if we were to Enter { 'firstname: 'bob', 'lastname': 'bob'} it wouldn’t insert.
Can mongodb do this?
You can do this in MongoDB through a compound index, like so :