With the rapid development of traditional databases, computer networks, and digital communication technology, the research and development of distributed database systems for data distribution storage and distribution is the main feature of distributed database systems that are increasingly received. However, due to its complex development, its development is restricted to a certain extent. Based on this, this paper proposes to develop a distributed database system in conjunction with the ADO.NET data access model in a .NET environment, greatly simplifying the development process. 1 Distributed Database System For its essence, the data of the distributed database system is logically unified, and physical dispersion is physically. Compared to centralized databases, it has the following main advantages: • Solving organizations dispersed and data requires interconnection. • Balanced load. The load is shared between each processing machine to avoid critical bottlenecks. ? High reliability. The data is distributed in different venues, and there are multiple copies, even if the individual venue is faulty, it is not caused by paralysis of the entire system. • Good expansion. When adding new relative autonomous organizational units, the expansion can be expanded in the case where the current mechanism has a minimum. Although there are many advantages, it also brings many new problems. Such as: data consistency problem, implementation of data remote delivery, reduction in communication overhead, etc., which makes it complicated to the development of distributed database systems. Fortunately, Microsoft's .NET development environment provides us with C # development language and ADO.NET data access models, combining both to develop distributed database systems to greatly simplify development work. 2 Remote Processing Framework and ADO.NET Development Distributed Database System Two important issues need to be resolved are: Data communication between each site and the operation and management of the database. Use C # combined with ADO.NET to efficiently and reliably solve these two problems. Specifically, the data can be easily resolved by using the .NET remote processing framework in C #, command remote delivery problem; C # operates through ADO.NET to make various operations for databases in distributed database systems , Reliable, easy to solve data consistency problems. 2.1 .NET Remote Processing Framework has three ways to implement data and commands. The first is to use a message or message, convert the data to be transmitted into a stream format, and then send to the remote host by a socket programming message. This method is troublesome and is not easy to implement. The second is to use the Web Service, ie the remote host provides a Web Service for a database query service. This method can only query a single site and unable to implement a multi-site joint query. The third is to use the .NET remote processing framework (.NET Remoting Framework) technology, it hides the technical details of the remote call, and the service program only needs to turn the local object to the remote object of the remote provider by simple settings. The client can access the remote object as transparently like accessing the local object, all messages, packets, etc. are handed over to .NET Remoting object processing, greatly simplifying the development. The general process of remote processing is shown in Figure 1: Figure 1 Remote Process First, the server side creates an instance of a server class, the remote processing system creates a proxy object representing the class and returns a proxy to the agent Quote. When the client calls the method, the remote processing infrastructure connection checks the type information and sends the call to the server process through the channel. Listening channels get this request and forward it to the server remote processing system, the server remote processing system lookup (or created when necessary) and calls the requested object. Then, this process will be performed in reverse, the server remote processing system will respond to the bundle of messages and sent by the server channel to the client channel. Finally, the client remote processing system returns the result of the call to the client object via a proxy. 2.2 ADO.NET ADO.NET is the core of the .NET database application with XML.
It uses offline data structures, data in the data source is cached into the Dataset object, and the user does not need to lock the data source, and the data is saved in XML format. 2.2.1 ADO.NET Management Data Consistency In a distributed database system, it is likely that multiple users have access to and modify data at the same time, so for distributed database systems, data consistency is indispensable. ADO.NET controls data consistency by using an optimistic consistency (actually DataSet objects to support the use of optimistic consistency control mechanisms), that is, the data line is only locked when it is truly updated in the database, and in pessimism In a consistency, the data line has been locked in this time from the extracted to the database. Therefore, using ADO.NET can respond to a large number of users within less time. In addition, in a distributed database system, it is often encountered when the user has modified since the line has been modified since the extracted, violates the consistency principles. The problem is also well resolved, that is, the DataSet object is used to maintain two versions for each modified record: the original version and the update version, before the updated record is written back to the database, you must first put the data. The original version of the centralized record is compared to the current version in the database. If two versions match, update records in the database; otherwise, there will be a violation of the principle of consistency. 3 Examples Development A Household Appliance Chain has a headquartering and many branches, headquarters and branches, and all stores often need to conduct a variety of information (such as the current price list, sales status and inventory information of each store), Organizational institutions establish a distributed database query system to achieve sharing of headquarters and store information for unified management. 3.1 System Design 3.1.1 System Structure Schematics Structure As shown in Figure 2: Figure 2 System Configuration Tower Headquarters and Each Branch Configure a server with fixed IP, other computers connected to the server, headquarters and each branch The server is coupled to the communication network. 3.1.2 System Implementation Step System Realization is divided into three main steps. First, design a database for headquarters and individual branches. Due to the large amount of data, SQL Server creates sales and inventory databases for each branch, and creates employee databases, the inventory database, credit card customer database, and supplier information database, and supplier information databases for headquarters. Second, a dynamic link library (DLL) that provides database services (DBSERVER) is required, and some of the services you want to use (such as remote objects) and functions (such as: Local Data table) Remote creation and deletion, intervals of data sheets, etc.) In this DLL, each branch needs to use this DLL to call some of the services and functions when queries. Finally, the client query interface is developed according to actual needs. 3.2 System Implementation Key Technologies 3.2.1 Remarks of Remote Objects and the first job you want to do after the system is running is to publish a local remote object and get the remote objects issued by other stores. When you release a remote object, first set a network port number, then create and register a channel, and finally post the server-side activation object. Other venues can easily obtain the released remote objects based on the IP address and the network port number.
The key code for implementing remote object publishing and acquisition is as follows: Remote object release: // Creating a channel instance, Port is the specified network port number TcPChannel MyChannel = New TcPChannel (int32.parse (port)); // Register ChannelServices. RegisterChannel (myChannel); // publisher server activates the subject RemotingConfiguration.RegisterWellKnownServiceType (typeof (DbServer), "STORE", WellKnownObjectMode.Singleton); get remote object: // try to obtain the corresponding remote object based on the IP address and port number {MYDBSERVER = (dbserver) Activator.getObject (TCP: // " IP ": " P " / store ");} // Capture Exception Catch (NullReferenceException Nullex) {MessageBox.show (" The specified URL address is not reached " Nullexp.Message);} Catch (RemotingException Remexp) {messagebox.show (" Specify the object definition is not " Remexp.Message);} 3.2.2 Database Access to Access to ADO.NET The database can easily connect to the database, import data in the data source into the DataSet object, and the DataSet objects can be done in the DataSet object itself can also be remotely passed remotely. This brings great convenience to develop distributed database systems. The key code to implement database access is as follows: // Establish a database connection string SQLCONN = "Initial catalog = store; data source = localhost; userid = sa; password =;"; sqlConnection conn = new SqlConnection (SQLCONN); conn; conn. Open (); // Open Database // Import Data in Data Source Try {Dataset DS = New Dataset (); DataTable DT = New DataTable ("Result"); SqlDataAdapter Adapter = New SqlDataAdapter (); SqlCommand mySqlDataSetCmd = new SqlCommand (cmdString, Conn); // cmdString for the command to be executed adapter.SelectCommand = mySqlDataSetCmd; adapter.Fill (dt); ds.Tables.Add (dt);} finally {Conn.Close (); // Close the connection of the database} 3.2.3 Query in the Split distributed database system is generally divided into three categories: local queries, remote query and joint queries. There is no difference between the local query and the centralized database; for remote queries, as long as you get the remote object, you can easily implement the query function; the most complicated query, involving data between multiple sites, table Remote creation, delivery, connection, merge and other technologies. The implementation of the joint query is described below. The second chain store is to query the air-conditioned inventory information supplied from all Beijing suppliers in the third and fourth chain stores in the fourth chain, which can be implemented by the following steps. First, get the headquarters and the remote objects released by the third and fourth chain stores.