I have an architecture where I have one primary database MyMainDatabase
. And then I create a separate database for each new customer CustDb###
. On my MainDatabase I have a table to keep track of all the customers databases CustomerDbTable
.
The customers database has a table called Invoices. The invoice id is a GUID therefore the probability of one repeating is very small.
So here is my question I have to look often for an Invoice given its id (GUID). I do not what approach to take:
Create a table in MyMainDatabase called AllInvoices that will have the columns IdOfInvoice, CustDatabaseName. Every time I create a invoice on the customer Database I will also create a record in
MyMainDatabase
Create a query that will enable to search an invoice in multiple databases. I have the name of the databases. I will prefer this apprach because on the first one every time I create a new invoice I have to remember to create it also on the MainDatabase