SharePoint Content Database简介

SharePoint作为微软主打的企业Portal平台,功能强大,使用简单,非常的方便。对于很多关系数据,我们可以使用自定义列表来维护,如果是非关系数据,可以使用文档库来维护。另外还可以在上面进行版本维护,工作流审批,而这一切可以不用写一行代码,只需要在界面和SharePoint Designer中进行设置即可完成。

虽然SharePoint很简单,很容易上手,但是对于开发人员来说,维护在其中的数据又怎么和其他系统进行集成呢,我们可以使用3种方法:

  • 在SharePoint Server使用C#程序,调用SharePoint对象模型,读取其中的各种数据。
  • 在客户端调用SharePoint的WebService,读取其中的数据。
  • 直连SQL Server SharePoint Content数据库,使用SQL来读取其中的数据。

前面两种方法,都是官方推荐的,文档详细,介绍较多,我就不讲了,我接下来主要研究如何直接读取SharePoint Content DB的数据。微软官方肯定是不推荐使用这种方法的,因为这个太底层了,完全脱离了SharePoint的控制,如果对其中数据进行直接的修改,那么可能会产生SharePoint无法预期的数据值。不过做数据库应用开发的都明白,这种方法执行效率最高,灵活性最大。为了避免写入无法预期的数据导致SharePoint崩溃,所以我们只是读取SharePoint Content DB,不做任何Update和Delete操作。要读取SharePoint Content DB的数据,首先要对其表结构做给基本的了解。

从网上(http://blogs.technet.com/b/praveenh/archive/2010/12/20/inside-a-sharepoint-content-db.aspx)找的一个简介的表格,介绍了主要的几个SharePoint Content DB Table:

Features Table that holds information about all the activated features for each site collection or site.
Sites Table that holds information about all the site collections for this content database.
Webs Table that holds information about all the specific sites (webs) in each site collection.
UserInfo Table that holds information about all the users for each site collection.
Groups Table that holds information about all the SharePoint groups in each site collection.
Roles Table that holds information about all the SharePoint roles (permission levels) for each site.
All Lists Table that holds information about lists for each site.
GroupMembership Table that holds information about all the SharePoint group members.
AllUserData Table that holds information about all the list items for each list.
AllDocs Table that holds information about all the documents (and all list items) for each document library and list.
RoleAssignment Table that holds information about all the users or SharePoint groups that are assigned to roles.
Sched Subscriptions Table that holds information about all the scheduled subscriptions (alerts) for each user.
ImmedSubscriptions Table that holds information about all the immediate subscriptions (alerts) for each user.
 

另外再配上了一个图,说明其中的关系。

SharePointContentDatabaseModel

其中最最重要的就是AllUserData这个表,我们可以从微软MSDN找的一些对几个核心表的介绍:

http://msdn.microsoft.com/en-us/library/hh625524(v=office.12).aspx

这个文档介绍的是最新的SharePoint2013的数据库结构,如果使用SharePoint2010或者07也不用担心,大部分字段都是一样的。如果SharePoint2003,还可以参考官方的另一个文档:

http://msdn.microsoft.com/en-us/library/dd587562(v=office.11).aspx

当然,仅仅有这么几个表还不够,在实际使用中,我们还需要关联其他的表进行联合查询,才能完成我们想要的东西。接下来我会写几个Case,一个一个的分析如何查询对应的表。

posted @ 2014-03-06 04:02  深蓝  阅读(2485)  评论(0编辑  收藏  举报

我要啦免费统计