Jun 25

Simple Classification of Database Management Systems & Introduction to Oracle DBMS

+ Classification of Database Management Systems
–Oracle
— Data Model

Oracle DBMS is world renowned as a relational database management system facilitating the relational model of data. The relational model was invented by E.F. (Ted) Codd as a general model of data. There are 12 rules sated by Codd, which needs to be adhered with, so that a database can be declared as a Relational model database. Oracle does adhere to most of the rules but provides the user the ability to violate the rules in order to extend the capabilities. Newer distributions of Oracle (10g and 11g) are capable of catering data requests relating other data models also i.e. RDF Data Model, Spatial Network Data Model. The necessary data transformations are performed by Data Interfacing Layers mostly written using Java. Recent ratings have claimed that Oracle is the number one Relational database provider.
—Number of Users
Oracle has a customer base of 250,000 customers, highest market share of 47.1% that is 7168 million USD in 2006; most of the customers are corporate organizations, which fulfill their data requirements using Oracle.
—Cost
Oracle has several database server configurations, each having different levels of functionalities and accordingly different levels of pricing. Oracle Express Edition is available freely but is limited to 4 GB of user data, 1 GB of RAM and single processor utilization. Standard ONE, Standard, and Enterprise are the other versions, which are priced according to the level of performance they offer, e.g. memory utilization, number of parallel processors etc.
—Number of Sites of distribution
Oracle can be considered as the number one enterprise preferred database server provider. Oracle is widely distributed in the high range and mid-range database market on UNIX and Linux platforms, Oracle has a fair stake on the windows based database servers market also.

–Microsoft SQL Server
— Data Model
Microsoft SQL Server is also a Relational model database management system. Like Oracle, Microsoft SQL Server also facilitates the usage of multiple data models in the recent versions. SQL Server 2008 supports the ADO.NET Entity Framework and the reporting tools, replication, and data definition will be built around the Entity Data Model. In 2008 Microsoft introduced LINQ to Relational Data which is an object-relational mapping (ORM) framework that allows the direct 1-1 mapping of a Microsoft SQL Server database to .NET classes, and query of the resulting objects using LINQ
—Number of Users
Microsoft SQL had a market share of 2654.4 million USD by the end of 2006, that’s a 15.6% of the total market share in 2006.
—Cost
Microsoft SQL Server 2008 has the option to be purchased under a server operating system license with incremental Client Access Licenses (CALs), or a per-processor license model. Express Edition, Compact Edition & Evaluation edition are the free versions. A free edition of Microsoft SQL Server is ideal for learning and building desktop and small server applications. Non fee editions are priced according to the functionality and the level of performance provided.
—Number of Sites of distribution
Microsoft SQL Server dominates the high range and mid-range database market on Microsoft Windows platforms. Microsoft SQL server has no stake on the Linux / UNIX market share because it is a Windows only version.

–My SQL
— Data Model
Like Oracle and MS SQL Server, MySQL is also a Relational model database management system. When we consider presentation and accessibility of data with other data models, MySQL is with poor ranking compared to Oracle and MS SQL Server i.e. When we consider Network model interfacing, both Oracle and MS SQL Server have recursive operators for processing recursive sets, though they all work a little differently. MySQL has no such special tools, though there is a graph engine under development for MySQL
—Number of Users
With over 65,000 downloads per day, MySQL has the highest adoption and growth. MySQL has gained 25% market share in overall database usage by developers in the past two years. MySQL continues to have the largest mindshare in the open source database market and has the highest number of paying customers for product support: an estimated 16,000.
—Cost
MySQL is available free of cost. MySQL is an “Open Source” database. MySQL is part of LAMP (Linux, Apache, MySQL, PHP / Perl / Python) environment, a fast growing open source enterprise software stack. More and more companies are using LAMP as an alternative to expensive proprietary software stacks because of its lower cost, reliability, and documentation.
—Number of Sites of distribution
MySQL is the world’s most popular open source database. Broad acceptance of MySQL can be attributed to the rapid overall adoption of the L/WAMP stack. Because of its popularity, MySQL has the support of leading IT organizations including major hardware and software vendors

+ Introduction to Oracle DBMS
–Sharing Data
Oracle provides several methods which can be used to share data among other DBMS. Additionally these methods provide a consistent way to perform logical database backup and recovery. Of these, the common utilities used are the import and export tools. Mostly they are used to move schema definitions and data between different Oracle instances and users. While still supported on 10g the original import (imp) and export (exp) utilities were replaced in 10g with the faster and more advanced Data Pump-based, impdp and expdp.

–Minimizing Redundancies and Inconsistency
As relational database Oracle provides the facilities to reduce redundancies and inconsistencies. Minimizing redundancy requires complex queries and schema structures, which in turn requires a high performance database system which is capable is fulfilling complex requests. Oracles highly scalable architecture and high performance therefore provides the ability to reduce redundancies and inconsistencies. Also the newest Oracle release Oracle Database 11g Release 2 contains Automatic Storage Management, Oracle Real Application Clusters, and Active Data Guard allow storage and server resources to be used for both fault tolerance and running production workloads, keeping servers and storage from sitting idle waiting for failures, thus reducing inconsistencies and redundancy.

–Support for Transactions
Oracle DBMS provides the support transactions. Oracle transactions act according to definitions defined by the SQL standard. A transaction is a sequence of SQL statements that Oracle treats as a single unit of work, every SQL DML (Data Manipulation Language) statement issued subsequently becomes a part of this transaction. When disconnecting from the database the transaction ends as well as when issued with a COMMIT or ROLLBACK command.

–Integrity
Oracle provides a number of integrity constraints and database triggers to facilitate the management of business rules. Referential integrity (foreign key constraint) is one way Oracle provides for maintaining business rules. Relational systems allow control of business rules with constraints, and referential integrity rules form the backbone of relational tables. Several types of constraints can be applied to Oracle tables to enforce data integrity, i.e. Check Constraint: validates incoming columns at row insert time, Not Null Constraint: used to specify that a column may never contain a NULL value, Primary Key Constraint: used to identify the primary key for a table, References Constraint: used to ensure that a row is not deleted, if rows still exist in a dependent table, Unique Constraint: used to ensure that all column values within a table does not contain duplicate entries.

–Security
Oracle database has many complex security measures which make it an ideal database system for enforcing tight security standards. Data confidentiality, integrity, and availability can all be well protected with properly designed Oracle database. Oracle allows for various types of authentication. Oracle-based authentication allows for Oracle database accounts with user-ids and strong password management. Oracle passwords are encrypted with a modified DES algorithm for each database connection. Oracle passwords are stored in an encrypted format in the data dictionary. All passwords are encrypted, including user passwords whether across the network or local connections, server to server passwords, and even database administrator passwords when the database is down. Oracle also supports host-based authentication which is based on the operating system’s user accounts which are then passed on to Oracle. Additional authentication options are available for those that choose the Oracle Advanced Security Option Oracle makes use of profiles to allow the administrator to place specific restrictions and controls on a number of system resources, password use and various Oracle products. These profiles can be defined, named, and then assigned to specific users or groups of users. By default, new Oracle users are not given any privileges. New users must be given privileges before they can logon or execute any database operation. Users can not do anything unless they have been given the specific privilege to do so. There are an impressive number of privileges that can be given, around 100 in all. There are two types of privileges available to be granted to users. They are system and object privileges. Roles are used to ease the management task of assigning a multitude of privileges to users. Roles are first created and then given sets of privileges that can be assigned to users and other roles. Users can be given multiple roles. It is much easier to create sub-sets of privileges that are organized into roles and then assign the role to one or more users. Roles can be protected with passwords. Roles that are protected with passwords require that a password be provided before activating a role unless it is the user’s default role. There are three standard types of auditing available in Oracle, including SQL statement-level, privilege-level, and object-level auditing. Audit records can be written to the standard Oracle audit table, to an operating system audit trail (dependent on operating system used), or to an external file.

–Standards
Oracle conforms to Entry level conformance defined in the ANSI document, X3.135-1992, “Database Language SQL.” Oracle supports the ASCII character set (FIPS PUB 1-2). Oracle supports both single-byte and multibyte character sets. Also Oracle provides extend functionality, which are not defined in standards, but provide valuable functionality.

May 22

Google Pac Man- Awesome JavaScripting!

Video taken on 22-05-2010 of the Google page which featured Pac Man Game.
It was totally JavaScript… This is FireBug‘s real-time analysis of page source dynamic behavior

More Info

May 15

My Definition of Life

Forget the past except moments I helped some one,

live for today, plan only for tomorrow,

expect & mitigate risk,

have a life goal,

don’t give up

despite any thing be nice.

That’s my definition of life

–Sudeera Jaysekara

Mar 11

True Friend

Friends

Feb 22

Quick Sort – Array Based


package project;

public class QuickSort {

    Comparable theArray[];

    public void sort(Comparable theArray[]) {
        this.theArray = theArray;
        sort_recursive(0, theArray.length - 1);
    }

    private void sort_recursive(int partition_start, int partition_end) {
        if (partition_start == partition_end) {
        return; //base case , it the sub array length is zero, then sorted
        }

        int pivotLocation = partition(partition_start, partition_end); //use the partition algorythm to find pivot location

        if (pivotLocation != partition_start) { //if the pivot is not the smallest value
            sort_recursive(partition_start, pivotLocation - 1); //then quick sort the values before the partition
        }

        if (pivotLocation != partition_end) {  //if the pivot is not the largest value
            sort_recursive(pivotLocation + 1, partition_end); //then quick sort the values after the partition
        }

    }
 //partition algorythm
    private int partition(int bottom, int top) {
        int down = bottom;
        int up = top;
        Comparable pivot = theArray[bottom];
        while (true) {
            while (!(theArray[down].compareTo(pivot) > 0)) {
                down++; // increase down pointer untill a value greater than pivot value is found
                if (down == top) {
                    break; //the boundry conditions of the partition
                }
            }
            while (!(theArray[up].compareTo(pivot) <= 0)) {
                up--; // decrease up pointer untill a value less than or equal to pivot value is found
                if (up == bottom) {
                    break;//the boundry conditions of the partition
                }
            }
            if (up > down) {
                Swapper.swap(theArray, up, down); //if up is greater than down then swap the up position value and down position value
            } else {
                Swapper.swap(theArray, up, bottom); //else then swap the up position value and pivot position value, here the pivot is selected as the first element in the sub array
                return up; //pivot location is  found, which is the up position
            }
        }
    }
}
package project;
//Swaps the values of two locations in a specific Array
public class Swapper {

    public static void swap(Comparable[] theArray, int position1, int position2) {
        Comparable temp = theArray[position1];
        theArray[position1] = theArray[position2];
        theArray[position2] = temp;
    }
}

Feb 22

Shell Sort – Array Based

package project;

public class ShellSort {

    Comparable theArray[];
    int length;

    public void sort(Comparable theArray[]) {
        this.theArray = theArray;
        length = theArray.length;
        shell_sort();
    }

    private void shell_sort() {
        int gap = length / 2;
        while (true) {
            for (int i = length - 1; i > i - gap && i > -1; i--) { //visit each element within one gap length from the last position , and check if one gap length is more than the array size
                for (int j = i; j - gap > -1; j = j - gap) { //visit each element one gap length apart from each other.
                    if (theArray[j - gap].compareTo(theArray[j]) > 0) { //comapare the two elements which are one gap length apart from each other
                        Swapper.swap(theArray, j, j - gap); // if the left element is greater than the right element then swap the left and right elemnts
                    }
                }
            }
            if (gap == 1) {
                return; //if gap length is one then the array is sorted
            }
            gap = gap / 2; //reduce the gap size by half and repeat the above insertion sort

        }
    }
}
package project;
//Swaps the values of two locations in a specific Array
public class Swapper {
    public static void swap(Comparable[] theArray, int position1, int position2) {
        Comparable temp = theArray[position1];
        theArray[position1] = theArray[position2];
        theArray[position2] = temp;
    }
}

Feb 22

Radix Sort – Integer Character – Array Based

package project;

public class RadixSort {

    String theArray[];
    int maxLength = 0;

    public char[] sort(char c[]) {
        toBinary(c);
        padZeros();
        radixSort();
        for (int j = 0; j < theArray.length; j++) {
            int b = Integer.parseInt(theArray[j], 2);
            c[j] = (char) b;
        }
        return c;
    }

    public int[] sort(int c[]) {
        toBinary(c);
        padZeros();
        radixSort();
        for (int j = 0; j < theArray.length; j++) {
            c[j] = Integer.parseInt(theArray[j], 2);
        }
        return c;
    }

    private void toBinary(char x[]) { //convertion to binary
        theArray = new String[x.length];
        for (int i = 0; i < x.length; i++) {
            theArray[i] = Integer.toBinaryString(x[i]);
        }
    }

    private void toBinary(int x[]) { //convertion to binary
        theArray = new String[x.length];
        for (int i = 0; i < x.length; i++) {
            theArray[i] = Integer.toBinaryString(x[i]);
        }
    }

//radix sort done using stright radix sort
    private void radixSort() {
        bit_evaluvation:
        for (int bit = theArray[0].length() - 1; bit > -1; bit--) {
            int zero, one = 0;
            //find the first occurence of one, upto that point it has zeros
            while (theArray[one].charAt(bit) != '1') {
                one++;
                if (one == theArray.length) {
                    continue bit_evaluvation; //All zeros no need to process this bit
                }
            }
            while (true) {
                //find the next occurence of zero
                zero = one;
                while (theArray[zero].charAt(bit) != '0') {
                    zero++;
                    if (zero == theArray.length) {
                        continue bit_evaluvation;// if it cannnot find a zero then evaluvation for this bit is finished
                    }
                }
                //shift array elemets from i to zero position by one element and copy the zero position value to the i position
                String tmp = theArray[zero];
                int j = zero;
                while (j - 1 >= one) {
                    theArray[j] = theArray[--j];
                }
                theArray[one] = tmp;
                one++; //go to next position, which is a one and repeat the above operation
                 if (one == theArray.length) {
                        continue bit_evaluvation;// if it cannnot find a next one then evaluvation for this bit is finished
                    }
            }
        }
    }

    private void padZeros() { //fill zeros to the front so that all binary strings are of equal length
        for (String s : theArray) {
            if (s.length() > maxLength) {
                maxLength = s.length();
            }
        }
        for (int j = 0; j < theArray.length; j++) {
            theArray[j] = String.format("%0" + maxLength + "d", Long.parseLong(theArray[j]));

        }
    }
}

Feb 22

Heap Sort – Array Based

package project;

public class HeapSort {

    Comparable theArray[];
    int length;

    public void sort(Comparable theArray[]) {
        this.theArray = theArray;
        length = theArray.length;
        bulidHeap(); //build the heap using the supplied array
        sortHeap(); //sort the created heap
    }

    private void bulidHeap() {
        for (int i = (length / 2) - 1; i > -1; i--) { //The second half of the array are leaf nodes, thus we will consider only the first half
            downHeap(i); //ensure heap condition is valid for each node which is a parent
        }
    }

    private void downHeap(int parent) {
        int greater = parent; //Assume the parent is greater than both the children
        while (true) {
            //find the index of the left child
            int left_child = parent * 2 + 1;
            //if there is no left child,then the heap condition is valid
            if (left_child >= length) {
                return;
            }
            //find if the left child has a greater value
            if (theArray[left_child].compareTo(theArray[parent]) > 0) {
                greater = left_child;
            }
            //find if a right child also exisits which is greater than the left child
            if (left_child + 1 < length && theArray[left_child + 1].compareTo(theArray[left_child]) > 0) {
                greater = left_child + 1;  //left_child+1 = right child's position
            }
            //if the parent is greater than both the children,then the heap condition is valid
            if (parent == greater) {
                return;
            }
            //swap the greater child with the parent
            Swapper.swap(theArray, parent, greater);
            //Consider the parents new location and evaluvate its heap condition with respect to its new children
            parent = greater;
        }

    }
    private void sortHeap() {
        while (length != 1) { //do untill only one node remains unsorted, which will be the smallest node
            Swapper.swap(theArray, 0, --length); //reduce the unsorted length by 1 and the swap the node at the last unsorted position with the root
            downHeap(0);//ensure the heap condition for the new root value
        }
    }
}
package project;
//Swaps the values of two locations in a specific Array
public class Swapper {

    public static void swap(Comparable[] theArray, int position1, int position2) {
        Comparable temp = theArray[position1];
        theArray[position1] = theArray[position2];
        theArray[position2] = temp;
    }
}

Feb 22

Specification of a ListNode in a LinkedList

public class ListNode {

    Object element;
    ListNode next;

    public ListNode(Object x, ListNode n) {
        element = x;
        next = n;
    }

    public ListNode(Object x) {
        this(x, null);
    }
}

Feb 22

Stack implemented using Linked lists

/* Linked list based Stack implementation */
public class StackUsingLinkedList {

    private ListNode tosNode; // The node which represents the top of the Stack

    public StackUsingLinkedList() { // Creates a stack with no nodes
        tosNode = null;
    }

    public boolean isEmpty() { // Checks if the Stack is empty
        return (tosNode == null);
    }

    public void makeEmpty() { // Empty the Stack by removing linked nodes
        tosNode = null;
    }

    public void push(Object x) { // Create new node and add the data, point to tos node, and make new tos

        tosNode = new ListNode(x, tosNode);
    }

    public void pop() throws Exception {
        if (isEmpty()) {  //Check if empty before pop
            throw new Exception("The Stack is empty: Stack pop");
        }
        tosNode = tosNode.next; //make the new tos point tos next of current tos

    }

    public Object top() throws Exception {
        if (isEmpty()) { //Check if empty before top
            throw new Exception("The Stack is empty: Stack top");
        }
        return tosNode.element; //return the element

    }

    public Object topAndPop() throws Exception {
        Object returnValue = top();  //keep the top node's value
        pop();  // pop and remove the top node
        return returnValue; //  return the top node's value
    }
}

Older posts «

» Newer posts