Reputation: 3964
I am using c# visual studio 2012 professional. making a web site asp.net I am building a shop - (each user can buy food, drinks etc) I have two databases - one for usernames and one for transactions. The databases are in the same project... I want every user to have his own chart/database with his name and transactions he's made. Instead of actually creating a brand new database for this, isn't there a way I can combine these two databases since they contain all the information I need? (I probably should have created one database with a table for transactions and a table for users...)
What's the best way to go about this situation?
Thanks in advance.
Let me know if you need me to give you more info.
Upvotes: 3
Views: 914
Reputation: 8913
You should not create separate database for each user.
Make Shops,Brands,Users and UsersTransaction tables and link them properly using primary key and foreign key.
Having said that you can query two or more databases on same server or on different server(Linked Server).
You can make a combined query for your databases as below:-
SELECT * FROM [server1].[database].[scheme].[table] A join [server2].[database].[scheme].[table] B on A.Id=B.Id
On your destination server you can use below query to insert data from other database:-
insert into [TableName](columns)
SELECT (columns) FROM [server].[database].[scheme].[table]
Upvotes: 2