sql server - Same database and domain(single db instance & Single site url) needs to use by different organizations? -


my product used different organizations.each organization having multiple users.one organization data should not accessed organization users(not @ relation 1 organization organization).for situation,i know can create separate database each organization.

but,i want use same database(single instance) handle multiple organization data.is possible? product developed asp.netmvc sql server.

thanks sella

it's not clear asking

but

if mean want use single database file matter of design in database tables . achieve requirement using such design :

1- create table contain organizations following schema :

   id      organizationname    ------------------------    1       microsoft    2       google 

2- in users table contains userid , password logging application add column name organizationid foreign key table have created in number 1 . users table :

id       username     password          organizationid ------------------------------------------------------ 1         admin         123                  1 2         james         12                   1 3         john          3213                 2 

in way when user logs application know organization working , consider in queries

3- in each table of database add column name organizationid foreign key table have created in number 1 . example employee table :

id     name       address          organizationid --------------------------------------------------------- 1     john          sampledata               1  

this organizationid column used in queries explain

4- in application , anywhere else (database stored procedures , webservices & …) when want insert , modify or retrieve data , consider logged in users organizationid operations . example if want query retrieve employees working in organization of logged in user :

select * employee organizationid = (select organizationid users id=currentuserid) 

where currentuserid logged in users id have maintained in session or ... according application


Comments