NAME : HELLEN M NYANHONGO
REG NO. : H150021N
PROGRAM : ELECTRONIC COMMERCE
COURSE : ADVANCED DATABASE
LECTURER : MR. NYAMUGUDZA
Examine how web services and data replication could be used in combination to support the application requirements for mobile internet applications. 15
To support the application requirements for mobile internet applications web services and data replication can be used. Web services refer to network accessible interfaces to application functionality, built using standard Internet technologies. Applications that can be accessed over a network using a combination of protocols like HTTP and XML, among others are web services. Data replication is the mutual sharing of information so as to ensure consistency between redundant resources, such as software or hardware components, to improve reliability, fault-tolerance, or accessibility.

Exposure of the Existing Function on the network -Any web service is generally a single unit of managed code that can be remotely invoked using HTTP, meaning that it can be activated as per HTTP requests. These web services enable the exposure of the existing functionalities of the code over the network. When the code is now connected to the network then it means the other application can now use the functions of the program that is being exposed to the network using HTTP.

Interoperability -This means that web services should be in position to run on any different platforms and also using different programming languages. Web services should allow various applications on the internet to communicate in terms of sharing data and services among each other on the internet. Typical example is thatASP.Net should be able to interact with VB.NET applications over the Web services. For this reason web services are technology dependent or at least that is what they should be.

Standardized Protocol – Web services use standardized industry standard protocol for the communication. All the four layers (Service Transport, XML Messaging, Service Description, and Service Discovery layers) use well-defined protocols in the web services protocol stack. This standardization of protocol stack gives the business many advantages such as a wide range of choices, reduction in the cost due to competition, and increase in the quality.

Low Cost Communication – Web services use SOAP over HTTP protocol, so you can use your existing low-cost internet for implementing web services. This solution is much less costly compared to proprietary solutions like EDI/B2B. Besides SOAP over HTTP, web services can also be implemented on other reliable transport mechanisms like FTP.

Availability—data replication ensures that data is available at all times. Developers find this crucial as the clients are guaranteed of information for the mobile internet applications. If one of the sites containing relation R fails, then the relation R can be obtained from another site. Thus, queries (involving relation R) can be continued to be processed in spite of the failure of one site.

Less Data Movement over Network – The more replicas of a relation are there, the greater are the chances that the required data is found where the transaction is executing. Hence, data replication reduces movement of data among sites and increases speed of processing. Moreover, transactional replication offers an excellent backup for frequent and daily changes in the database.

Snapshot Replication – Snapshot replication distributes data exactly as it appears at a specific moment in time does not monitor for updates to the data. The entire snapshot is generated and sent to Users. Snapshot replication is generally used when data changes are infrequent. It is bit slower than transactional because on each attempt it moves multiple records from one end to the other end. Snapshot replication is a good way to perform initial synchronization between the publisher and the subscriber.

Merge Replication – Merge replication is a method for copying and distributing data and database objects from one SQL Server database to another followed by synchronizing the databases for consistency. The other methods for replication of SQL databases are snapshot replication and transactional replication. Data from two or more databases is combined into a single database. A key characteristic of merge replication is that it permits both the primary server (publisher) and the subscriber servers to independently modify the database. All changes are synchronized by merge agents installed on all servers, and a preconfigured conflict resolution mechanism kicks in to solve any data conflicts. Version-related data conflicts are common with merge replication as updates to the database happen irregularly when there is a connection between the publisher and the subscriber.

However data replication leads to inconsistency of files containing data. When there are multiple copies and that one copy is being modified, the copy will be different from the other replicas. If the copy is being modified and is not propagated to other copies. It will make the other copies outdated.

Compare and contrast optimistic and pessimistic approaches to concurrence control in the management of conflicting database transactions. 15
Optimistic concurrency control (OCC) is a concurrency control method applied to transactional systems such as relational database management systems and software transactional memory. OCC assumes that multiple transactions can frequently complete without interfering with each other. While running, transactions use data resources without acquiring locks on those resources.

Optimistic locking assumes that although conflicts are possible, they will be very rare. Instead of locking every record every time that it is used, the system just looks for indications that two users actually did try to update the same record concurrently.

OCC locks the record only when an update is taking place. It ensures that the locks are held between selecting, updating, or deleting rows. The process requires a way to ensure that the changes to data are not performed between the time of being read and being altered. This is achieved using timestamps, hashtags.

The advantages of optimistic concurrency control include that, it reduces the time for which a given resource is unavailable which is used by another transaction. Also the control method provides better scalability, as less physical database connections used. On the other hand it has the disadvantage that the version verification is not executed until the transaction is committed.

Pessimistic, or negative, concurrency control is when a record is locked at the time the user begins the edit process.  In this concurrency mode, the record remains locked for the interval of the edit. One advantage is that no other user is able to get a lock or control on the record for updating, it can inform any requesting user that they cannot update the record because it is in use. Additionally, if the applications are able to perform activities outside the control of the database rollback capabilities the activities do not take place if a conflict occurs.

There are several drawbacks to pessimistic concurrency control.  If the user goes for a break, the record remains locked, denying anyone else the ability to update the record, even if it has been untouched by the initial requestor.  Also, in order to maintain record locks, a persistent connection to the database server is required. Certain sequences of operations are rejected even though they do not violate the chosen degree of isolation. By allowing these operations to be accepted, a higher concurrency can be achieved and thus a higher scalability is possible
Moreover web applications can have a lot of simultaneous users, a persistent connection to the database cannot be maintained without having remarkable resources on the database server. As such, applications that use pessimistic concurrency would require additional licenses for use.  Because of this drawback, almost all applications use optimistic concurrency control.

Optimistic Concurrency approach Pessimistic Concurrency approach
Allow concurrency conflict happens and if it happens, we react on it in some manner
Protects system from concurrency conflict so it will not happen
Best solution when concurrency possibility is rather low
Best solution when concurrency possibility is rather low
Suits best when database has a lot of records and not too many (relatively) users
Suits well when we have a table with relatively small amount of records but a lot of update operations.

References:
1 Elmasri, R., Navathe, S. B., Fundamentals of database systems 6th ed., Addison-Wesley, Pearson Education, ISBN 13: 978-0-136-08620-8
2 Iqra Basharat, Farooque Azam, Abdul Wahab Muzaffar,(2012)”Database Security and Encryption: A Survey Study”, International Journal of Computer Applications (0975 – 888) Volume 47– No.12,
3.Emil Burtescu,(2009)”DATABASE SECURITY – ATTACKS AND CONTROL METHODS”, Journal of Applied Quantitative Methods, Vol. 4, no. 4.

4. www.tutorialspoint.com/dbms/dbms_concurrency