You are on page 1of 8

Assignment of Open Source Technologies (CAP- 304)

Assignment 1

SUBMITTED BY: SUBMITTED TO:

Name: Hunney Salhotra Ms. Mandeep Kaur

Class: BCA-MCA Dept: CSE\IT

Reg no.: 3010060019

Roll no.: 06
Homework Title/Number: 1 Course Code: CAP304
Course Instructor: Ms. Mandeep Kaur Course Tutor: _________
Date of Allotment: 15-02-2010 Date of Submission: 01-03-2010
Student Roll Number: 06 Section: D3601

Declaration:
I declare that this assignment is my individual work. I have not copied from any other student's
work or from any other source except where due acknowledgement is made explicitly in the text,
nor has any part been written for me by another person.

Hunney Salhotra
(Student Signature)
Evaluator’s Comment:
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
________________________

Marks Obtained: ____________ Out Of:_______________________


Q1. Compare and contrast features of SQL and MySQL?
Ans. When considering a utility for data management the two most popular choices are MySQL
and SQL Server. Both are efficient at keeping your data organized and readily available through
a user interface, but they differ drastically in many areas. In the following discussion we will
review the major differences in detail to help clear the air about the most common question asked
in data management discussions: "Which is better, MySQL or SQL Server?"
Some key questions to ask yourself in determining which data management tool is best suited for
your needs are:
o How flexible do you need your data to be?
o How secure must your data be?
o Do you need support in utilizing your data management tools?

Standard Language Support

An important aspect of database development is how to access your data using different standard
based protocols. Both MySQL and SQL Server do a good job of supporting all major protocols
for accessing their respective databases. A standard protocol is the "programming language" used
for a program to communicate to a SQL database. The most common protocol is called tSQL, or
Transact SQL. Transact SQL is a series of statements that a program can use to access data and
create new tables in a SQL database. The statements can INSERT new records, DELETE old
records and UPDATE existing records, along with a myriad of other functions.
The international standard for this programming language is referred to as ANSI SQL. ANSI
stands for American National Standards Institute. ANSI is a collective governing body that
determines what the standard language will be. For example, ANSI decides such things as the
word INSERT will be used in the programming language as opposed to the work ADD to insert
a new record into a database.
While both databases do a good job of supporting all major protocols, one of the most frequent
complaints about MySQL is that it does not completely follow the ANSI SQL standard. This
would not necessarily be any issue if your need for data storage never outgrows the capability of
MySQL. However, if you data is constantly growing, there may be an eventual need to upgrade
from MySQL to SQL Server to handle the vast amounts of data. In a situation like this, any
application that has been written to manipulate a MySQL database will have to be revisited to be
sure that the program is able to "communicate" with the new data store.

Security Support

Another major concern to business today is security. While data management can seem to be a
mundane process at times, securing critical data from "the outside world" is an ever increasing
and trying task.
While is good to know that your database management system (MySQL or SQL Server) utilize
security features it is very important to know that the application has been verified by a third
party. SQL Server has been certified as C2 compliant, which ensures that the database has
adequate security support for government applications.
Along with C2 certification, Microsoft Baseline Security Analyzer helps administrators ensure
that their SQL Server installations are up to date with the most current patches and security
features. MySQL has no equivalent tool to protect and ensure the same confidence in their
platform.

Data Protection

Another security aspect is the protection from loss of data due to power failure. Database
administrators in large environments employ the concept of "warm standby servers". This is an
additional server containing duplicate data that, by normal use, is not accessed until an event
such as a power failure of the main server. Standby servers are kept in a ready state using a
concept known as log shipping. Log shipping takes a regularly scheduled backup (sometimes at
intervals of less than 10 seconds) of a database and stores that data on the duplicate standby
server´s hardware.
MySQL lacks the capability to perform such a backup transaction in an online, or "live"
environment. This feature is standard to SQL Server and includes tools to help the database
administrator manage the details of the log shipping.

Support and Service

When deciding on how you want to manage your data, you must also consider what kind of
support you can expect to receive from the manufacturer of your data management application.
After all, if you can´t figure out how to make it work for you, you can´t make any use of your
data.
MySQL and SQL Server both offer support plans that are available from their respective
vendors. Both applications offer some free support as well as some paid support options and
plans.
MySQL claims to employ about 100 people worldwide, which makes up the entire company
consisting of product development, support staff, sales staff, distribution, and clerical workers.
With such a small staff dispersed over a wide area of expertises, this fact may worry some
database administrators.

Pricing

Now, let´s move on to the biggest issue of them all. Pricing! Let´s start with MySQL, how does
FREE sound? Well, while MySQL is an open source database management tool, it does have its
retractions on that $0.00 price! MySQL can be used, for free, for any purpose whether its used to
manage a large companies data or to spice up a hobbyist´s web site.
SQL Server on the other hand, could take a small independent company´s budget and eat it for
lunch! However, the many outstanding features that are far and away above MySQL offset the
price paid for SQL Server drastically.
Q2. Multi-user access in MySQL can be managed through locking. Explain how.
Ans.
Introduction: Concurrency and isolation control facilities in MySQL
• Meta-data locks: implemented inside the table cache. Provide isolation for Data
Definition Language (DDL) operations. A specific type of a metadata lock is called
Name Lock. (layer: SQL)
• Table-level data locks (layer: SQL)
• Engine-specific mechanisms - row locks, page locks, table locks, versioning
(implemented inside engines)
• The global read lock - necessary to support FLUSH TABLES WITH READ LOCK
(layer: SQL)

Life cycle of a table during statement execution


A typical execution flow for a Data Manipulation Language (DML) statement:
• compute the set of all tables used in the statement
• For each table:
o "open" the table - get a TABLE object from the table cache and acquire a meta-
data lock on the table
• Wait if GLOBAL READ LOCK and the statement changes data
• For each table:
o "lock" the table - acquire a table-level data lock on the table
• execute the statement:
o calls handler::write_row()/read_rnd()/read_index(), etc.
o engine-level locking facilities are invoked implicitly
• For each table:
o release the data lock on the table
• For each table:
o release the DDL lock on the table and put the table back into the table cache
There is no typical execution scheme for DDL statements.

Q3. Is it true that MySQL works in a layered structure? Justify with reason.
Ans. The overall organization of the MySQL server architecture is a layered, but not particularly
hierarchical, structure. We make the distinction here that the subsystems in the MySQL server
architecture are quite independent of each other.
In a hierarchical organization, subsystems depend on each other in order to function, as
components derive from a tree-like set of classes. While there are indeed tree-like organiza-tions
of classes within some of the subsystems—notably in the SQL parsing and optimization
subsystem—the subsystems themselves do not follow a hierarchical arrangement.
A base function library and a select group of subsystems handle lower-level responsibilities.
These libraries and subsystems serve to support the abstraction of the storage engine systems,
which feed data to requesting client programs. Figure 1 shows a general depiction of this
layering, with different subsystems identified.
Note that client programs interact with an abstracted API for the storage engines. This enables
client connections to issue statements that are storage-engine agnostic, meaning the client does
not need to know which storage engine is handling the data request. No special client functions
are required to return InnoDB records versus MyISAM records. This arrangement enables
MySQL to extend its functionality to different storage requirements and media.

Q4. Elaborate ACID concept of MySQL. What are these features and also discuss their
advantages.
Ans. The ACID model is one of the oldest and most important concepts of database theory. It
sets forward four goals that every database management system must strive to achieve:
atomicity, consistency, isolation and durability. No database that fails to meet any of these four
goals can be considered reliable.

• Atomicity states that database modifications must follow an “all or nothing” rule. Each
transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction
fails. It is critical that the database management system maintain the atomic nature of
transactions in spite of any DBMS, operating system or hardware failure.
• Consistency states that only valid data will be written to the database. If, for some reason,
a transaction is executed that violates the database’s consistency rules, the entire
transaction will be rolled back and the database will be restored to a state consistent with
those rules. On the other hand, if a transaction successfully executes, it will take the
database from one state that is consistent with the rules to another state that is also
consistent with the rules.
• Isolation requires that multiple transactions occurring at the same time not impact each
other’s execution. For example, if Joe issues a transaction against a database at the same
time that Mary issues a different transaction, both transactions should operate on the
database in an isolated manner. The database should either perform Joe’s entire
transaction before executing Mary’s or vice-versa. This prevents Joe’s transaction from
reading intermediate data produced as a side effect of part of Mary’s transaction that will
not eventually be committed to the database. Note that the isolation property does not
ensure which transaction will execute first, merely that they will not interfere with each
other.
• Durability ensures that any transaction committed to the database will not be lost.
Durability is ensured through the use of database backups and transaction logs that
facilitate the restoration of committed transactions in spite of any subsequent software or
hardware failures.

Q5. Write the role of InnoDB component of MySQL.


Ans. InnoDB is less well known than the default MyISAM table type. However, there are several
reasons why it could be better choice for your web application.
1. Data integrity and foreign key constraints: Foreign keys establish a relationship between
columns in one table and those in another. For example, you might create a library
application where books can be loaned to members. A foreign key constraint would
ensure that a member existed before a book could be checked-out. Similarly, removing a
user would not be possible until all their books were returned.
2. Transactions: InnoDB tables support transactions. A transaction allows multiple SQL
commands to be treated as a single and reliable unit.
Consider a banking application where you are transferring money from one account to
another. The transaction would only be committed if both accounts were altered
successfully. If anything failed, the database would be rolled-back to a previous state.
In addition, InnoDB tables recover well from crashes. MySQL will analyze the log files
to ensure the data is accurate so there is no need to repair tables.
3. Row-level locking: InnoDB uses row-level rather than table-level locking. If a row is
being inserted, updated or deleted, only changes to the same row are held up until that
request has completed. Tables that receive more updates than selects may be faster with
InnoDB.

Q6. Discuss mechanism to limit the number of rows in a MySQL query? Give example.
Ans. The LIMIT clause is used to limit the number of results returned in a MySQL statement. So
if you have 1000 rows in a table, but only want to return the first 10, you would do something
like this:
SELECT column FROM table
LIMIT 10
This is similar to the TOP clause on Microsoft SQL Server. However the LIMIT clause always
goes at the end of the query on MySQL, and PostgreSQL.

You might also like