如何为公司维护单独的数据库 [英] How to maintain separate database for company

查看:58
本文介绍了如何为公司维护单独的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VB.net和SQL2005开发了Windows应用程序

我数据库中的表为

公司,客户,供应商,购买,销售表...

我需要帮助才能进行以下工作.....

当用户创建一个新公司时,要以公司名称创建单独的数据库,该公司的数据要存储在该公司的数据库中.....



给这个想法.........


I deveploped windows application Using VB.net and SQL2005

I had tables in the database as

Company,Customer,Supplier,Purchase,Sales tables...

I need help for do the following work.....

When the user create one new company, separate database want to create at the name of company,,,, data of the particular company want to store in it''s database.....



Give idea for this.........


推荐答案

您必须根据需要创建数据库,或者在数据库中创建一个全新的层,以便一个数据库可以容纳许多公司的数据.或者您是说如何通过安装程序分发数据库?使用SQL Server精简版是最有意义的,因为它是免费的.

创建表
公司
开始
id int identity(1,1),
名称nvarchar(200),
用户名nvarchar(200),
密码nvarchar(200)
结束

我会在另一张表中有用户名,所以一个公司可能有很多用户名,但是,要点是,company.id现在作为标识符添加到当前的顶级表中,然后该表下面的任何数据都会映射通过中间表,因此它也与公司相关联.现在,您的应用程序需要进行数据库登录,这意味着该应用程序创建或使用的所有数据将仅对该公司的用户可见.

这些都是假设您拥有一台DB服务器,所有这些不同的公司都将使用.
You have to create databases as needed, or create a whole new layer in your DB, so that one DB can hold data for many companies. Or do you mean how do you DISTRIBUTE a DB with your installer ? Using SQL Server lite edition makes the most sense, as it is free.

CREATE TABLE
COMPANY
begin
id int identity(1,1),
name nvarchar(200),
username nvarchar(200),
password nvarchar(200)
end

I''d have usernames in another table, so there could be many for one company, but, the point is, company.id is now added as an identifier to your current top level tables, and then any data below that, maps back through the middle table so it is also associated with a company. Now your app needs to require a DB login, which will mean any data it creates or uses, will only be visible to users from that company.

This is all assuming you have ONE DB server, that all these DIFFERENT companies will use.


这篇关于如何为公司维护单独的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆