views:

163

answers:

3

I am planning to use ASP.NET MVC2 implemented membership system to manage users. Database that uses application should have tables that are related with these users. Is it possible to use two different databases and make relationships (foreign keys) between them or I will have to merge these two databases into one?

Thanks,
Ile

+1  A: 

It is NOT possible to put up relationships between databases. You CAN use triggers to ensure relational integrity.

Otherwise I would say: all in one database, put them into different schemata.

TomTom
"You CAN use triggers to ensure relational integrity" - What does this actually mean? Could you please be more precise? Thanks
ile
Well, a trigger (read up the documentation - actually a set of triggers) can be used to enfoce relational integrity. It is properly documented in - the documentation. http://msdn.microsoft.com/en-us/magazine/cc164047.aspx has an introduction on what triggers are.
TomTom
A: 

I would put membership/roles in a separate database. I don't think having foreign key constraints is that useful. Its better decoupling if you go through the membership API rather than join with the tables directly. The only thing in the membership database you might need to look up often is the username. If thats becomes a performance problem I'd probably just create an lookup table, either in memory or in a lookup table in the other component's database.

Frank Schwieterman
I there is a need to (for example) log/audit changes against a user identifier or to define "ownership" of data by user how do you reconcile the above?Foreign key constraints are self evidently useful?
Murph
Add a column to store the guid the membership provider uses to identify the user. You can write this information to the log whether or not the DB enforces referential integrity.
Frank Schwieterman
A: 

Hey buddy, I've posted an answer on this exact topic right here

I Hope it helps !

:-Dan

danfromisrael
That's my topic by the way :D :D Thanks anyway, I'll write you a note out there which I forgot :))
ile