Database Management System
Source:Database and Network Journal Author:David Anderson
You know that a data is a collection of logically related data elements that may be structured in various ways to meet the multiple processing and retrieval needs of organizations and individuals. There’s nothing new about data base-early ones were chiseled in stone, penned on scrolls, and written on index cards. But now database are commonly recorded on magnetically media, and computer programs are required to perform the necessary storage and retrieval operations.
The system software package that handles the difficult tasks associated with created, accessing, and maintaining database records is in a DBMS package establish an interface between the database itself and the users of the database. (These users may be applications programmers, managers and others with information needs, and various OS programmers.)
A DBMS can organize, process, and present selected data elements from the database. This capability enables decision makers to search. Probe, and query data contents in order to extract answers to nonrecurring and unplanned questions that aren’t available in regular reports. These questions might initially be vague and/or poorly defined, but people can “browse” through the database until they have the needed information. In short, the DBMS will “manage” the stored data items and assemble the needed items from the common database in response to the queries of those who aren’t programmers. In a file-oriented system, users
1
2012
needing special information may communicate their needs to a programmers, who, when time permits, will information. The availability of a DBMS, however, offers users a much faster alternative communications patch (see figure).
Special, direct, and other file processing approaches ate used to organize and structure data in single files. But a DBMS is able to integrate data elements from several files to answer specific user inquiries fir information. This means that the DBMS is able to structure and tie together the logically related data from several large files.
Logical structures. Identifying these logical relationships is a job of the data administrator. A data definition language is used for this purpose. The DBMS may then
Employ one of the following logical structuring techniques during storage access, and retrieval operation: list structures, hierarchical (tree) structures, and network structures, relational structures.
1. List structures. In this logical approach, records are linked together by the use of pointers. A pointer is a data item in one record that identifies the storage location of another logically related record. Records in a customer master file, for example, will contain the name and address of each customer, and an account number identifies each record in this file. During an accounting period, a customer may maintain an invoice file to reflect these transactions. A list structure could be used in this situation to show the unpaid invoices at any given time. Each in the
2
2012
customer file would point to the record location of the first invoice for that customer in the invoice file. This invoice record, in turn would be linked to later invoice for the customer. The last invoice in the chain would be identified by the use of a special character as a pointer.
2. Hierarchical structures. In this logical approach, data units are structured in multiple levels that graphically resemble an “upside down” tree with the root at the top and the branches formed below, there’s a superior-subordinate relationship in a hierarchical structure. Below the single-root data component are subordinate elements (or one) has only a single owner. Thus, as we see in figure, a customer owns an invoice, and the invoice has subordinate items. The branches in a tree structure are not connected.
3. Network structures. Unlike the tree approach, which dose not permit the connection of branches, the network structure permits the connection of the nodes in a multidirectional manner. Thus, each node may have several owners and may, in turn, own any number of other data units. Data, management software permits the extraction of the needed information from such a structure by beginning with any record in a file.
4. Relational structures. A relational structure is made up of many tables. The data are stored in the form of “relations” in these tables. For example, relation tables could be established to link a college course with the instructor of the course, and with the location of the in order to find the name of the instructor and the location of the English class, the course/instructor relation is searched to get
3
2012
the name, and the course/location relation is searched to get the class location. Many other relations are of course, possible. This is a relatively new database structuring approach that’s expected to be widely implemented in the future.
5. Physical structure. People visualize or structure data in logical ways for there
Own purposes. Thus, records R1 and R2 may always be logically linked and processed in sequence in one particular application. However, in a computer system it’s quite possible that these records that are logically contiguous in one application are not physically stored together. Rather, the physical structure of the I/O and storage devices techniques used, but also on the different logical relationships that users may assign to the data found on R1 and R2. For example, R1 and R2 may be records of credit customers who have shipments send to the same block in the same city every two weeks. From the shipping department manager’s perspective, then, R1 and R2 are sequential entries on a geographically organized shipping report. But may be identified, and their accounts may be processed, according to their account numbers which are widely separated. In short, then the physical location of the stored records in many computer-based information systems is invisible to users.
During the past five years, Microsoft has promoted Data Access Objects (DAO), and then Remote Data Objects (RDO), and now ActiveX Data Objects (ADO) as the primary data access technology for Visual Basic developers. It seems that Microsoft has been pushing a different data access technology with each successive version of Microsoft Visual Studio. Today, new versions of ADO are
4
2012
available on Microsoft's Web site and ship with other products and technologies, such as Microsoft Windows 2000, Microsoft Windows NT 4 Service Packs, Microsoft Internet Explorer versions 3 and later, Microsoft SQL Server 6.5 Service Pack 5 and SQL Server 7, Microsoft Office 2000, and even Microsoft Expedia Streets & Trips 2000.
One of the goals of ADO is to simplify data access. ADO is built upon some fairly
complex
technologies—OLE
DB
and
ODBC
(open
database
connectivity)—and is designed to allow you to programmatically access and modify data stored in a wide variety of databases. This broad reach is a departure from previous data access technologies. For the sake of comparison, let's take a quick glance at ADO's predecessors: DAO and RDO.
Data Access Objects
DAO was originally designed to interact with Microsoft Access databases. Although you can use DAO to access SQL Server and Oracle databases, many developers complain about DAO's performance with these large database systems. Others complain that DAO doesn't permit programmers to access some of the richer, more powerful features of SQL Server and Oracle, such as output and return parameters on stored procedures.
One of my coworkers likes to say that using DAO to work with an Oracle database is like performing brain surgery on you…without anesthetics…while wearing oven mitts. Extreme? Yes—but he does have a point. DAO is tuned to work
5
2012
with desktop databases, not client/server databases. Frustrated by DAO's performance and access limitations, developers who wanted to work with SQL Server and Oracle databases generally sought other options.
Remote Data Objects
Microsoft provided another option in RDO, which originally released with Visual Basic 4 Enterprise Edition. RDO's object model closely resembles the hierarchy of structures in the ODBC API. Programmers found that RDO provided much faster access to client/server database systems, such as SQL Server and Oracle, than DAO did. Although those familiar with the ODBC API quickly learned how to work with the RDO object model, developers lacking experience with that API, such as those who had been using DAO, found the RDO technology difficult to use.
The object model itself wasn't the problem for most programmers learning RDO: the nuances inherited from the ODBC API posed the greatest obstacles. Suddenly, programmers had to bone up on cursors and bookmarks. They had to learn many of the ins and outs of specific database systems. Does the error message \"The connection is busy with results from another hstmt\" ring any bells out there? If you try to do the impossible on an ODBC connection to your database, RDO won't save you. Instead, you'll get that error. DAO hid the problem from you by automatically creating another connection to your database to perform the action you requested.
6
2012
Another challenge that RDO posed for programmers accustomed to writing DAO code was that RDO lacked many of DAO's features, such as sorting, searching, and filtering. Other DAO functionality unavailable in the RDO world includes data definition language (DDL) interfaces to ODBC API functions such as Create Table and Create Field.
Best of Both Worlds: ActiveX Data Objects
Programmers clamored for a data access technology that combined the simplicity and relative ease of use of DAO with the speed, power, and control of RDO. Initially introduced as part of the Microsoft Internet Information Server 3 package, ADO was intended to be all things to all people. Of course, such lofty goals are rarely fulfilled.
While the initial release of ADO lacked many of Rod’s features, I believe that ADO 2.0 offered comparable functionality. Certain RDO features, such as mixed cursors, have yet to be implemented in ADO, but these features are few and far between. In fact, I'm at a loss to name a single significant feature available in RDO that was not available in ADO 2.0 in one form or another. (I'm sure someone will tell me otherwise; a great way to find such features is to make a statement like that in a book like this.)
With the release of version 2.1, ADO and its supporting libraries began offering nearly all features available in DAO. DDL libraries were added to ADO in version 2.1 to provide functionality similar to functions available with DAO, such as
7
2012
Create Table, Create Field, and Create Index. Microsoft Jet and Replication Objects (JRO) in ADO 2.1 offers much of the Jet-specific functionality available via the DB Engine object in DAO. ADO 2.1 also added functionality to simplify the retrieval of newly generated identity values. ADO 2.5 adds no new functionality to more closely match the capabilities of DAO and RDO, because perhaps the only place where ADO lags behind DAO is in its searching and filtering capabilities.
So ADO has most of the functionality of RDO and DAO as well as many helpful features not available in previous data access technologies.
Database Management
There are problems with traditional data management. A more subtle problem is data dependency. When a problem’s logic is tied to it’s physical data structure, changing that structure will almost certainly require changing the program. As a result, programs using traditional access methods can be difficult to maintain. The solution to both problems id often organizing the data as a single, integrated database. The task of controlling access to all the data can then be concentrated in a centralized database management system.
How dose the use of a centralized database solve the data redundancy problem? All data are collected and stored in a single place; consequently, there is one and only one copy of any given data element. When the value of an element (an address, for example) changes, the single database copy is corrected. Any program requiring access to this data element gets the same value, because there
8
2012
is only one value.
How dose a database help to solve the data dependency problem? Since the responsibility for accessing the physical data rests with the database management system, the programmer can ignore the physical data structure. As a result, programs tend to be much less dependent upon their data, and are generally much easier to maintain. Expect the trend toward database management to continue.
9
2012
数据库管理系统
来源:数据库和网络杂志
作者:大卫·安德森
众所周知,数据库是逻辑上相关的数据源集合。这些数据源可以按照不同的结构组织起来,以满足单位和个人的多方面的要求。数据库本身并没有什么新东西——早期的数据库凿在石头上,记在名册上,以及写在索引卡中。而现在普遍记录在可磁化的介质上,并且需要用计算机程序来执行必须的存储和检索操作。
处理与创建、访问以及维护数据库记录有关的复杂任务的系统软件包叫做数据管理。DBMS软件包中的程序在数据库及其用户间建立接口(这些用户可以是应用程序员)。
DBMS可组织、处理和显示从数据库选择的数据源。该功能可以是决策者搜索、试探和查询数据库的内容,从而对正式报告中没有的、不再出现的、且无计划的问题做出回答。这些问题最初可能是模糊的并且/或者是定义拙劣的,但是人们可以浏览数据库知道获得数据的答案。简言之, DBMS将“管理”存储的数据项,并从公共数据库中汇集所需的数据项来响应那些非程序员的询问。在面向文件的系统中,需要特定的用户可以将它们的要求传送给数据员,并准备信息。但是使用DBMS可为用户提供一个更快的、用户可选择的通信方式。
顺序的直接的以及其它的文件处理方式通常用于单个文件中的组织和结构,而DBMS可综合多个文件的数据项,并回答某个用户对信息的查询。这意味着DBMS能够访问和检索非关键字字段的数据,即 DBMS能够将几个大文件中逻辑相关的数据组织并联在一起。
10
2012
逻辑结构。确定这些逻辑关系是数据库管理者的任务,由数据定义语言完成。DBMS在存储、访问和检索操作过程中可以选用的逻辑技术有:1表结构2层次(树型)结构3网状结构4关系性结构。
1.表结构。在该逻辑方式中,记录通过指针连接在一起。指针是记录中的一个数据项,它指出另一个逻辑相关的记录的存储位置。例如,顾客主文件中的记录将包含每个顾客的姓名和地址,而且该文件中的每个记录都由一个账号标识。在记帐时期,顾客可以在不同时间购买许多东西。因此,公司保存一个发票文件来反应这些交易,这种情况下,可使用表结构显示任意时间为支付的发票。顾客文件中的每个记录都将包含这样一个记录,该链的最后一个记录有一个作为指针的特殊字符标识。
2.层次结构。该逻辑方式中,数据单元的多级结构类似一棵倒立的树,该树
的树根在顶部,而树枝向下延伸。在层次结构中存在主从关系,唯一的根数据下是从属的元或节点,而每个从属的元或节点又一次“拥有”一个或多个元或节点。该结构中根下面的每个元或树枝都只有一个所有者,这样一个用户拥有一个发票,而发票又有一个从属。在树型结构中,树枝不能相连。
3.网状结构。网状结构不像树型结构那样不允许树枝相连,它允许节点间多个方向相连。这样每个节点都有几个所有者,而它又可能有任意多个其它数据单元。数据管理软件允许从文件的任意记录开始提取该记录中的所有信息。
4.关系型结构。关系型结构由许多表组成,数据则以关系的形式存储在这些表中。例如,可以建立一些表将大学课程与该课程的老师以及上课的地点连接起来。为找到英语课的上课地点和教师名,现查询课程/教师关系得到名字,然后再查询课程/地点关系得到地
11
2012
点,当然也可以得到其它关系。这是一个新颖的数据组织技术,将来有望得到广泛应用。
5.物理结构:人们总是为了各自的目的,按逻辑方式设想或组织数据。这样,在一个具体应用中,记录R1和R2是逻辑相连且是按顺序处理的。但是,在计算机系统中,这些在一个应用中逻辑上邻接的记录,物理上完全可能不存储在一起。即录在介质和硬件中的物理结构不仅取决于用户定义的R1和R2中的数据的逻辑关系。例如,R1和R2可能是持有信用卡的用户记录而用户要求每两周将货物运送到同一个城市的同一个街区。而从运输部的管理规则看,R1和R2是按地理位置组织运输记录的顺序项。都是在A/R应用中,可找到R1和R2表示的顾客,并可根据其完全不同的账户处理它们的账目。简言之,在许计算机化的信息记录中,存储记录的物理单元,用户是看不见的。
关于数据访问技术的发展和最好的数据访问技术(ADO)
在过去的五年里,微软不断推出开发人员所用的主要数据访问技术,首先是Data Access Objects(DAO),然后是Remote Data Objects(RDO),现在是ActiveX Data Objects(ADO)。现在,新版本的ADO已经出现在微软的WEB站点上。ADO的目标之一是简化数据访问。ADO建立在一些相当复杂的技术上,如OLE Db 和 ODBC(开放式数据库连接),并且是为了能够对存放于很多种不同类型的数据库中的数据以编程方式进行访问和修改而设计的。正是这种更为广泛的访问范围,使ADO有别于以前的数据访问技术。为了便于比较,我们首先简单地看看ADO以前的技术:DAO 和RDO。
数据访问对象(DAO)
DAO 最初是为了与Microsoft Access 数据库进行交互而设计的。虽然可以使用DAO访问SQL Server 和 Oracle 数据库,但是很多开发人员都抱怨DAO应用于这些大
12
2012
型数据库时性能太差。还有人抱怨DAO不允许程序员访问SQL Server 和 Oracle 的一些更为珍贵的、功能更为前大的性能,例如存储过程中的输出和返回参数等。使用ADO处理Oracle 数据库就相对自己进行脑部外科手术,不进行麻醉。是的,DAO的设计意图是处理桌面数据库的,而不是客户机/服务器类型的数据库。由于DAO的性能和访问局限性令人感到沮丧,因此想要使用SQL Server 和 Oracle 数据库的开发人员通常寻找其他方法。
远程数据访问对象(RDO)
微软提供的另一种选择是RDO,它最初随Visual Basic 4企业版发行。RDO对象模型与ODBC API中的结构层次非常类似。程序员会发现与ADO相比,RDO大大提高了对诸如SQL Server 和 Oracle 的客户机/服务器类型数据库系统的访问速度。虽然熟悉ODBC API 的开发人员会很快学会如何使用RDO对象模型,但是缺乏使用API经验的开发人员,比如一直使用DAO的人,则发现RDO技术很难使用。
对于大多数学习RDO的程序员而言,对象模型的本身不是问题,而从ODBC API 所继承而来的细微差别造成了最大的障碍。突然之间,程序员们不得不专心致志于临时表和书签。他们必须学习特定数据库的很多入口和出口。错误消息“The connection is busy with results from another hstmt”是否会在出错得体放给出提示?基于数据库的ODBC 连接所不能实现的操作,RDO也不会支持。相反的,指挥得到上面的错误消息。而DAO则通过自动地创建另外一个数据库连接来执行要求的操作,从而隐含了这个问题。
对于习惯于写DAO代码的程序员而言,RDO所带来的另一个挑战是RDO 不具备ADO的很多功能,例如排序,查找和过滤等。RDO所不具备的其他DAO功能包括ODBC API 函数的数据定义语言(DDL)接口,例如 Create Table 和 Create Field。
13
2012
4.最好的数据访问技术:ActiveX Data Objects
这种数据访问技术,它能够把DAO的简单性和使用上的方便性与RDO的速度、能力和控制相结合。而最初作为Microsoft Internet Information Server 3 软件包一部分出现的ADO,正是希望成为对于所有人都适合的技术。当然,这种理想的目标几乎不可能实现。
虽然 ADO 最初的版本缺少很多RDO 的功能,但是ADO2.0提供了同样的功能。某些RDO 功能,如混合临时表,在ADO中还没有实现,但是这些功能都是很少使用的。事实上,很难找到一个在RDO中非常有用的功能,而在ADO中找不到。
随着2.1版本的出现,ADO及其支持库开始提供DAO所具备的几乎所有功能。在2.1版中加入了DDL库,以提供类似于DAO中诸如Create Table 、Create Field 和Create Index 等函数的功能。ADO 2.1中的Microsoft Jet 和 Replication Objects (JRO) 提供在DAO中通过DBEngine 对想实现的Jet特有的大部分功能。ADO2.1还增加了简化检索新产生的标识值的性能。ADO2.5 并没有增加使之与DAO和RDO功能更为接近的新功能,这是因为ADO 落后于DAO的唯一方面是其搜索和过滤能力。因此,ADO拥有了RDO 和DAO的绝大多数功能,同时还有很多以前的数据访问技术所没有的有益功能。
数据库的管理
传统的数据库管理存在着一些问题,许多问题是由于单独地考虑应用而引起的。较错综复杂是数据的依赖性。当程序的逻辑结构受到他的物理数据结构的束缚的时候,改变了数据结构,肯定要改变程序,引出的结果是采用传统存取方法的程序很难维护。解决以上问题的方法经常是把数据组成一体化的数据库,这样就能把控制存取所有数据任务集中在一个中心的数据库管理系统中。
14
2012
使用集中化数据库如何解决数据冗余问题呢?把所有的数据都收集和存放在一个地方,因此任意给定的数据元素只有一个拷贝。当一元素的值例如地址改变时,只修正唯一的数据拷贝,要求这些数据元素的任何一个程序都能得到同样的值。
数据库又如何协助解决数据依赖性问题呢?由于存取数据的责任由数据库系统承担,因此程序员就可不考虑实际的数据结构,导致了程序更少地以来于它的数据,一般是更容易维护了。可以预料,数据库管理会继续向前发展。
15
因篇幅问题不能全部显示,请点此查看更多更全内容