Lab 1 Introduction To My SQL
Lab 1 Introduction To My SQL
DATABASE
In today’s interconnected world, it’s almost impossible to find a business that doesn’t depend
on information in some form or another. Be it marketing data, financial movements or operational
statistics, businesses today live or die by their ability to manage, massage and filter information flow in
order to achieve a competitive advantage.
What is Database?
A database is a separate application that stores a collection of data. Each database has one or
more distinct APIs for creating, accessing, managing, searching and replicating the data it holds.
Other kinds of data stores can be used, such as files on the file system or large hash tables in memory
but data fetching and writing would not be so fast and easy with those types of systems.
So nowadays, we use relational database management systems (RDBMS) to store and manage huge
volume of data. This is called relational database because all the data is stored into different tables and
relations are established using primary keys or other keys known as foreign keys.
RDBMS Terminology:
Before we proceed to explain MySQL database system, let's revise few definitions related to database.
Table: A table is a matrix with data. A table in a database looks like a simple spreadsheet.
Column: One column (data element) contains data of one and the same kind, for example the
column postcode.
Row: A row (= tuple, entry or record) is a group of related data, for example the data of one
subscription.
Primary Key: A primary key is unique. A key value can not occur twice in one table. With a
key, you can find at most one row.
Foreign Key: A foreign key is the linking pin between two tables.
Referential Integrity: Referential Integrity makes sure that a foreign key value always points
to an existing row.
Centre for Diploma Studies Page 4/8
Department of Information Technology Session 2015/2016
Experiment’s Title: Introduction to MySQL Semester 1
MySQL Database
MySQL is a fast, easy-to-use RDBMS being used for many small and big businesses. MySQL is
developed, marketed, and supported by MySQL AB, which is a Swedish company. MySQL is
becoming so popular because of many good reasons:
MySQL is released under an open-source license. So you have nothing to pay to use it.
MySQL is a very powerful program in its own right. It handles a large subset of the
functionality of the most expensive and powerful database packages.
MySQL works on many operating systems and with many languages including PHP, PERL, C,
C++, JAVA, etc.
MySQL works very quickly and works well even with large data sets.
MySQL is very friendly to PHP, the most appreciated language for web development.
MySQL supports large databases, up to 50 million rows or more in a table. The default file
size limit for a table is 4GB, but you can increase this (if your operating system can handle it)
to a theoretical limit of 8 million terabytes (TB).
MySQL is customizable. The open-source GPL license allows programmers to modify the
MySQL software to fit their own specific environments.
MySQL Architecture
Centre for Diploma Studies Page 5/8
Department of Information Technology Session 2015/2016
Experiment’s Title: Introduction to MySQL Semester 1
A storage engine is a software module that a database management system uses to create, read, update
data from a database. There are two types of storage engines in MySQL. Transactional and non-
transactional.
The default storage engine for MySQL prior to version 5.5 was MyISAM. For MySQL 5.5 and later,
the default storage engine is InnoDB. Choosing the right storage engine is an important strategic
decision, which will impact future development. In this tutorial, we will be using MyISAM, InnoDB,
Memory and CSV storage engines. If you are new to MySQL and your are studying the MySQL
database management system, then this is not much of a concern. If you are planning a production
database, then things become more complicated.
MyISAM
InnoDB
Memory
CSV
Centre for Diploma Studies Page 6/8
Department of Information Technology Session 2015/2016
Experiment’s Title: Introduction to MySQL Semester 1
Merge
Archive
Federated
Blackhole
Example
MyISAM is the original storage engine. It is a fast storage engine. It does not support transactions.
MyISAM provides table-level locking. It is used most in Web, data warehousing.
InnoDB is the most widely used storage engine with transaction support. It is an ACID compliant
storage engine. It supports row-level locking, crash recovery and multi-version concurrency control. It
is the only engine which provides foreign key referential integrity constraint.
Memory storage engine creates tables in memory. It is the fastest engine. It provides table-level
locking. It does not support transactions. Memory storage engine is ideal for creating temporary tables
or quick lookups. The data is lost when the database is restarted.
CSV stores data in CSV files. It provides great flexibility, because data in this format is easily
integrated into other applications.
Merge operates on underlying MyISAM tables. Merge tables help manage large volumes of data more
easily. It logically groups a series of identical MyISAM tables, and references them as one object.
Good for data warehousing environments.
Archive storage engine is optimised for high speed inserting. It compresses data as it is inserted. It does
not support transactions. It is ideal for storing, retrieving large amounts of seldom referenced historical,
archived data.
The Blackhole storage engine accepts but does not store data. Retrievals always return an empty set.
The functionality can be used in distributed database design where data is automatically replicated, but
not stored locally. This storage engine can be used to perform performance tests or other testing.
Federated storage engine offers the ability to separate MySQL servers to create one logical database
from many physical servers. Queries on the local server are automatically executed on the remote
(federated) tables. No data is stored on the local tables. It is good for distributed environments.
No storage engine is ideal for all circumstances. Some perform best under certain conditions and
perform worse in other situations. There are tradeoffs than must be considered. A more secure solution
takes more resources. It might be slower, take more CPU time and disk space. MySQL is very flexible
in the fact that it provides several different storage engines. Some of them, like the Archive engine, are
created to be used in specific situations. Ironically this also brings a question, which storage engine to
Centre for Diploma Studies Page 7/8
Department of Information Technology Session 2015/2016
Experiment’s Title: Introduction to MySQL Semester 1
In some cases, the answer is clear. Whenever we are dealing with some payment systems, we are
obliged to use the most secure solution. We cannot afford to loose such sensitive data. InnoDB is the
way to go. If we want full-text search, than we must choose MyISAM. Only InnoDB supports foreign
key referential integrity constraint and if we plan to use this constraint, then the choice is clear. In many
situations we must have enough experience to choose the right engine. And if we lack the experience,
than the best way is to ask some seasoned developer. One of the best ways is to ask on specific Internet
forums. stackoverflow.com is a great one. The question is further complicated by the fact that we can
choose different storage engines for different tables.
A graphical user interface (GUI) is a type of interface that allows users to interact with
electronic devices or programs through graphical icons and visual indicators such as secondary
notation, as opposed to text-based interfaces, typed command labels or text navigation. GUIs are easier
to learn than command-line interfaces (CLIs), which require commands to be typed on the keyboard.
Third-party proprietary and free graphical administration applications (or "front ends") are
available that integrate with MySQL and enable users to work with database structure and data
visually.
Centre for Diploma Studies Page 8/8
Department of Information Technology Session 2015/2016
Experiment’s Title: Introduction to MySQL Semester 1
QUESTIONS
1. Explain on the differences between DBMS Microsoft Access (that you’ve learned in
Introduction to IT course last year) and MySQL. State at least FOUR (4) criteria/attributes.
2. Explain on THREE (3) well-known front ends for MySQL complete with images.
Note:
SPECIFICATION OF LAB SHEET ANSWERS
Cover
Content at least 10 pages.
Reference