I am creating a web application that uses IndexedBD. I come from the background of SQL, so the concepts are different. In particular, I understand that there is no real concept of a "foreign key" in an indexed DB. Thus, I am trying to find the fastest way to get a related object, which in the SQL world will be a foreign key.
For example, with SQL, suppose we have the following tables:
table carBrand:
brandName
brandInitial
table carModel:
modelName
brand (FK)
Now, if we have an entry in carBrandthat contains brandName=Ford, brandInitial='F'and then to record carModelthat contains data modelName = Mustangand brand = (FK)Ford.
To display brandInitialthis entry Mustangin the SQL world, I could use the dot "." notation. Just myCarInstance.brand.brandInitialthat will display F. I do not need to store in brandInitialthe record carModel, because a pointer to a foreign key stores this data.
Now, by going to indexedDB, the same script will be configured like this:
objectStore "carBrand"
objectStore "carModel"
To have the same record (Ford Mustang), I understand that we will make two calls .add. First add brandName: "Ford". Further (and here, when my understanding of "best practices" is not solid), to add a "Ford Mustang", we added an entry to the repository carModelthat contains this data:
modelName: "Mustang"
brand: "Ford"
, "" brandInital? F - , ?