Posts Tagged ‘sql server’

Android tablet application

Tuesday, June 22nd, 2010

Android applications ; connect with sql-databases

Android tablet for mobility

This Android project is possibly one the first of its kind in the industry. Our client, a leading hotelier was on the looking for an easy to use mobile application for restaurant order management that would talk to their existing bespoke ERP suite built on an open source relational database, a middle tier application and a set of desktop client applications to manage operations such as housekeeping, inventory, kitchen order and front office. Being amongst the top eating places in the city, the restaurant had a regular clientele, who enjoyed the traditional cuisine being served.

The challenge was in building a thick client application on a the android tablet device that communicated with the legacy database, preparing kitchen order tickets and posting them to production. Since there were no ready to use SOAP components, our engineers used industry standard RPC communication frameworks to enable the android app talk to the middle tier – which in turn transacted with the SQL relational database.  The android applications' SQL Lite database was engaged to store basic configuration information and temporary order records. The user friendly GUI ensured that non technical end user managers were able to take orders and suggest the best combination of speciality dishes to the discerning client. The application is under beta release for client feedback with enhancements planned for the next schedule development sprint.
  • SqlLite
  • Remobjects remoting middle tier server on Windows 2008
  • Relational database
  • Tablet PC running Android version 1.67

The middle tier framework is designed to support industry standard databases such as Oracle, Sql-sever, mySQL, pgSQL, FirbirdSql and DB2 express C

Interested in building a similar android application for your client ?

Call us today to discuss the possibilities.

    Transaction Isolation levels

    Tuesday, June 1st, 2010

    Isolation levels come into play when a transaction requires an exclusive right to use a resource thereby isolating it from other transactions. This isolation is provided by obtaining locks on the resource. What locks need to be set for the transaction is determined by SQL Server referring to the Isolation Level that has been set. Lower Isolation Levels allow multiple users to access the resource simultaneously thereby increasing concurrency but also introducing the possibility of concurrency related problems. Higher Isolation Levels eliminate concurrency related problems and increase the data accuracy but they may introduce blocking and in some cases result in deadlocks.


    The isolation levels defined by the ANSI/ISO SQL standard are:

    TRANSACTION ISOLATION LEVEL READ UNCOMMITTED:

    This level of isolation allows users to read data that has not been committed. This increases throughput since the user does not have to wait for the other transaction to complete its execution before it can read the data. But if the user reads data that has been modified by another transaction, which happens to fail at some point of time and roll-back, the data read initially by the user, is wrong or inconsistent. This is called dirty reads. To illustrate with an example, 

    Create a new database.

    Create table Employee with the following fields: Emp_Name, Salary

    Open two query windows in SQL Server and execute the following lines of code.

    First query window:

    begintran

    UPDATE [Employee]
    SET [Emp_Name]='ABC',
        [Salary]=1234

    Second query window:

    begintran

    SETTRANSACTIONISOLATIONLEVELREAD UNCOMMITTED
    SELECT*FROM [Employee]

    Execute the query in the first window. After that, execute the second query in a different query window. Note that the transaction in the first window has not committed or ended.

    The result of the select statement gives,

    Emp_Name | Salary
    ABC| 1234

    Now go back to the first query window and execute the command,

    ROLLBACKTRAN

    The value in the [Employee] table goes back to the original value, say ‘DEF’.

    So the second user ended up with the wrong data or was subjected to a dirty read. This happens because the level of isolation allows you to read data that is not yet committed.

    TRANSACTION ISOLATION LEVEL READ COMMITTED:

    It offers a higher level of isolation as it prevents users from reading data that has not been commited yet.
    Execute the same steps as above, after changing the level of isolation as‘READ COMMITTED’ in the second query window.

    First query window:

    begintran

    UPDATE [Employee]
    SET [Emp_Name]= 'ABC',
        [Salary]=1234

    Second query window:

    begintran

    SETTRANSACTIONISOLATIONLEVELREAD COMMITTED
    SELECT*FROM [Employee]

    Execute the query in the first window.Now on executing the second query, we do not get any result and the status is shown as ‘executing’.

    SQL query
    Now go back to the first query window and commit the transaction.

    committran

    As soon as the first transaction commits, the result is displayed in the second query window. As a result, the end-user always gets data that is consistent.In this isolation level, read locks are acquired on selected data but they are released immediately whereas write locks are released only at the end of the transaction. This level of isolationhas an adverse effect on performance as the second process has to wait for the first transaction to commit.

    TRANSACTION ISOLATION LEVEL REPEATABLE READ:

    This level of isolation implies that once a transaction reads existing data, read data would never be changed in that transaction irrespective of how many times the same select statement is issued.

    Consider the case where two users are accessing data from the same table. User1 beginstransaction and executes a select query on the table. At the same time user2 performs an update on the same table. Read Committed isolation level does not prevent this from happening. Now when user1 executesthe same select query again, within the same transaction he gets a set of values different from the first select statement.This is a data consistency problem related to Read Committed isolation Level called Non Repeatable Read.

    This can be avoided in Repeatable Read Isolation level by not releasing Shared Locks (acquired to read data)till the end of transaction. Therefore in the above mentioned scenario, user2 will have to wait till shared locks on the data are released, thus allowing the update only after the first transaction completes execution.

    In Repeatable Read Isolation level a select statement also would hold locks till the end of transaction. Again as the level of isolation increases, understand how Concurrency is gradually coming down.

    TRANSACTION ISOLATION LEVEL SERIALIZABLE:

    This is the highest level of isolation, where each statement is executed serially in an isolated manner. i.e, each statement is executed one after the other. Almost all database anomalies including phantom reads are eliminated in this level of isolation.

    Consider the case where two users are accessing data from the same table. User1 starts his transaction and executes a select query on the table. At the same time user2 performs an insert on the same table. TheRepeatable Read Isolation level prevents updates on data holding a shared lock, but it allows new rows to be inserted.Now when user1 executes the same select query again, within the same transaction, it returns an extra row which was not expected by the first user. This is the problem of phantom reads.

    The serializable isolation level does not allow updates on data till the current transaction completes execution. It also prevents new rows to be inserted to the table until the transaction completes, thereby returning the same result set no matter how many times the same select statement is executed within a single transaction. But this level of isolation has a serious effect on concurrency thereby reducing performance. So it should be used only in circumstances which require a high level of data consistency.

    The above four isolation levels are said to provide pessimistic control, because they acquire locks on data foreseeing the problems related to concurrency. There are two more levels of isolation which are new to SqlServer that provide optimistic control.UnderOptimistic Control, SQL Server does not hold locks but once read checks for inconsistency for the next read.

    The two new levels of isolation are:
    SNAPSHOT ISOLATION LEVEL:

    This Isolation Level prevents all concurrency related problems just like Serializable Isolation Level; in addition to that it allows multiple updates for the same resource by different transactions at the same time. It maintains consistent versions of records in a version store.

    When a user performs a select statement on a set of records it obtains a versioned copy from the version store. Every time a select statement is issued, the last consistent copy of the record, when the transaction started, is returned and the same version is read during the entire transaction, irrespective of the data being modified by other transactions. Now a second user also obtains a versioned copy and performs some updates on the data and commits the transaction. Now if the first user tries to perform an update on the data, the SqlServer detects this conflict and aborts the transaction.If another transaction starts changing the same record, another version will be stored and so on; resulting in a longer linked list in the version store. Maintaining and traversing through longer lists will impact the performance.  SQL Server keeps versions of the record until there is no reference for it.

    READ COMMITTED SNAPSHOT ISOLATION LEVEL:
    The only difference between ReadCommitted and Read Committed Snapshot isolation levels is that, Read Committed Snapshot is Optimistic whereas Read Committed is Pessimistic.

    Read Committed Snapshot Isolation Level is set at the database level. It differs from Snapshot in two ways; Unlike Snapshot, it always returns the latest consistent version and there is no conflict detection. Since this level does not require maintaining previous versions, there will be no impact for performance like Snapshot but all the concurrency related problems except dirty reads can happen.


    -DB Team                                                      

      Caching with dependencies

      Monday, February 15th, 2010

       

      This blog is continuation of our blog on Data caching

      Caching with Dependencies

      As time passes, the information in your data source may change. If your code uses caching, you may be unaware of the changes and might continue using out-of date information from the cache. To overcome this problem cache dependencies are introduced. They allow a cached item be dependent on another resource so that when that resource changes the cached item is removed automatically.

      Three types of dependencies mainly play in caching.

      • Dependencies on other cached items
      • Dependencies in files or folders
      • Dependencies on a Database query

      File Dependencies

      To use cache dependency, you need to create a cache dependency object, then need to supply that dependency object, while add a new cached item. For example when we create a cache dependency object that depends on an XML file, when the file is changed, the cache dependency will be invalidated and the dependent cached item will be evicted from the cache immediately.

      We can also specify a directory that needs to be monitored for changes, or we can supply an array of string that represents multiple files and directories.

      Cache Item dependencies

      Here we can create a cached item that’s dependent on another item in the cache. Now, when the first cached item changes or is removed from the cache, the second will automatically be dropped from the cache as well.

      SQL Server Cache Dependencies

      A more complex kind of cache dependency is the SQL Server cache dependency. SQL cache dependencies provide the ability to automatically invalidate a cached data object, when related data is modified in the database.

      SQL Cache dependencies still entails more complexity than just using a time based expiration policy. It’s more difficult to set up, and it can be more of a headache to maintain. If it’s acceptable for certain information to be used without reflecting all the most recent changes (and developers often overestimate the importance of up-to-the millisecond live information), you may not need at all.

      SQL Server 2005 and 2008 have built in notification infrastructure called “Service Broker”. This manages queues, which are database objects that have the same standing as table, stored procedures, or views.

      When using notification with SQL Server, we get following benefits.

      • Notification is much finer grained- Instead of invalidating our cached object when the table changes, SQL Server invalidate the cached object only when a row that affects codes query is inserted, updated or deleted.
      • It’s more intelligent-A notification message is sent the first time the data is changed but not if the data is changed again (unless we register for notification messages by adding an item back to the cache).
      • No special steps are required to set up notification-We just need to call a start service once in our code to enable. There is no other complex coding steps involves.

      There are the most important rules to manage notifications. If you break one of these rules, you won’t receive an error. However, the notification message will be sent as soon as you register, and cached item will be invalidated immediately.

        Caching – A performance booster

        Tuesday, June 16th, 2009

        For years, technology products have used caching to bring high performance. Simply put a cache becomes most of the time, the final solution to increase the performance of a data request. Page and DNS Caching are now critical for all operations in the wired space. Recently caching became really popular for Database access management.

        Caching provides two key benefits for Internet users

        • Reduce latency – Though the requests satisfy from the cache, which is closer to the client, caching reduces the overall network latency and returns much faster pages to the browsers.
        • Reduce network traffic – Caching, for some extent reduces the network bandwidth requirement as much as 35 percentage. Because most of the requests gets fulfilled locally and can avoid the transfer over expensive WAN. This saves money if the host charges for the traffic.

        Web Caching

        A web Cache lies between one or more web servers and clients, which analyzes the requests comes, save copies (HTML, images and files) and waits for another request for the same and responds with the saved copies instead of asking for the original to server it again. While Caching used to store Database information, retrieving the information from database takes time. With careful optimization we can reduce the time and lessen the burden imposed on database to a certain extent, but sure we can never eliminate it. In the case of page caching, cache server monitors which page object are frequently requested and store those objects locally. When these objects are later requested, the cache delivers it from local storage rather than forwarding the requests on to the original server.

        Web Caching can mainly divided into

        To know more about Web Caching and Data Caching click the above links. You can directly write to us for any queries.

          Microsoft dotnet Technologies

          Wednesday, April 22nd, 2009

          T4 code generation approach for faster project deliveries.

          Over the last 10 years, we have built considerable expertise in ASP.NET web application development using ASP.NET 2.0/3.5, AJAX, payment gateway integration using Worldpay, paypal etc to build complex intranets and ecommerce applications for web development.

          Third party components, controls and tools like ABCpdf.net, Aurigma Mass Image uploader are used commonly by our aspnet web development team. We also have expertise in tools like Silverlight and Sharepoint Server 2007

          • Data Access Layer using custom objects or typed data sets based on the project requirements.
          • Middle tier abstract for business layer
          • Provider Independent Data Access Layer using ADONET provider pattern.
          • Custom controls by inheriting existing controls or creating compound controls and components
          • ASPNET 2.0 Security, Membership, and Role Management – Implementation
          • ASPNET page level and data level caching to boost application performance
          • Domain objects serialized into XML and persisted in database.
          • Image and Graphics programming. in C#
          • ASPNET themes for skinning websites
          • Microsoft excel manipulation – Read and Writing excel files
          • Custom windows services using C# managed code
          • Active directory accounts authentication system for ASPNET intranet web application
          • Communication using MSMQ

          ASPNET Ajax:

          • ASPNET Ajax Control Tool Kit
          • ASPNET Ajax UI Effects – UI manipulations like Drag n drop, sorting, reordering, resizing and pagination.
          • ASPNET Ajax Custom Control Extenders – Developing custom client components using AJAX framework.
          • Script globalization and localization using AJAX framework.
          • Web services and page methods using JavaScript and ASPNET AJAX.
          • ASPNET Page method – To implement popular JavaScript frameworks and scripting libraries like JQuery.
          • Prototype and YahooUI.

          SQL Server 2000/2005/2008:

          • Database design.
          • Normalization.
          • Query Optimization.
          • Stored Procedures.
          • User defined functions.
          • Crosstab queries.
          • Site Search implementation using Full Text Catalog and Indexing.

          Payment Integration:

          • PROTX
          • WorldPay
          • Paypal
          • Authorize.NET
          • Google Checkout
          • HSBC API / CPI

          Third Party Components, Controls and Tools:

          • ABCpdf.net.
          • netCharting.
          • Aurigma Mass Image Uploader.
          • PDFBox – .NET Version.
          • iText.NET.

          Other Frameworks and Script Libraries:

          • Jquery
          • Lightwindow
          • Scriptaculous
          • Prototype
          • Yahoo UI
          • Google Map Geo coding based on UK Post Codes
          • Open ID Integration
          • Social Bookmarking
          • Open Source CMS Integration – Umbraco
          • ELMAH: Error Logging Modules and Handlers – To log, handle and mail runtime errors.

          ASPNET 3.5:

          • URL Rewriting and routing
          • ASPNET Dynamic data using scaffolding framework (Full CRUD operations supported)
          • History Control, Drag overlay extender, Media Control, XAML and Web Part manager,
          • LINQ
          • Powerful URL mapping component that enables to build applications with clean URLs.
          • REST-friendly naming patterns.
          • Silverlight – application using WCF service

           

          Our Microsoft aspnet web application team practices continous integration and agile scum methodologies to build enterprise web applications for our associates spread across London, New York, Washington and Seattle.

          Read about our Microsoft dotnet case studies

          To have a no obligation quote please click following link Contact Us.