Introduction To Mysql Server: Mysql Cluster - Provides Fault Tolerance
Introduction To Mysql Server: Mysql Cluster - Provides Fault Tolerance
Introduction To Mysql Server: Mysql Cluster - Provides Fault Tolerance
MySQL is the most popular open source (i.e. it is free) relational database
management system that is designed to provide an efficient data management.
MySQL is a reliable, efficient and easy to use. MySQL doesn‟t have a built in
„window‟ like interface unless you download and install it separately.
MySQL is very suitable for web-based applications and it runs in many of the
world‟s demanding websites like yahoo, Google, Youtube, etc.
MySQL Products
In this our lab practices we are going to use MySQL community server and
MySQL Workbench
Overview of SQL
The name SQL stands for "Structured Query Language". SQL is a user-friendly
commercial query language. A query language is a high - level Data
Manipulation Language (DML) which is used in stand-alone interactive manner.
SQL is a standard interactive and programming language for querying and
modifying data and managing databases. The core of SQL is formed by a
command language that allows the retrieval (selection), insertion, updating, and
deletion of data, and performing management and administrative functions.
SQL Terminology
Table - A set of rows. It is analogous to a “file”.
Row - Analogous to a record of a “file”.
Column - A column is analogous to a field of a record. Each column in a
given row has a single value.
Primary Key – One of more columns whose contents are unique
Within a table and thus can be used to identify a row of that table.
MySQL is capable of supporting many data types. Some of the more commonly
used include:
CHAR (n)
CHAR's are used to represent fixed length strings. A CHAR string can range
from 1-255 characters. E.g. StudentName CHAR (30).
VARCHAR (n)
VARCHAR is a more flexible form of the CHAR data type. It also represents
data of type String, yet stores this data in variable length format. Again,
VARCHAR can hold 1-255 characters. E.g. StudentAddress VARCHAR (30).
FLOAT [(n,d)]
A FLOAT represents small decimal numbers, used when a somewhat more
precise representation of a number is required.
DATE
Stores date related information. The default format is 'YYYY-MM-DD', and
ranges from '0000-00-00' to '9999-12-31'. MySQL provides a powerful set of
date formatting and manipulation commands, too numerous to be covered
within this article. However, one can find these functions covered in detail
within the MySQL documentation.
TEXT / BLOB
The TEXT and BLOB data types are used when a string of 255 - 65535
characters is required to be stored. This is useful when one would need to store
an article such as the one you are reading. However, there is no end space
truncation as with VARCHAR AND CHAR. The only difference between
BLOB and TEXT is that TEXT is compared case insensitively, while BLOB is
compared case sensitively.
SET
A data type of type string that allows one to choose from a designated set of
values, be it one value or several values. One can list up to 64 values in a set.
ENUM
Is a short for ENUMERATION. It is a data type of type string that has the same
characteristics as that of SET data type, but only one set of allowed values may
be chosen. Usually only takes up one byte of space, thus saving time and space
within a table.
You can list up to 65535 values in an ENUM list. If a value is inserted that is
not in the list, a blank value will be inserted.
Records
For this laboratory exercise we are going to use the banking application that you
have seen in laboratory exercise one. Before proceeding consider the following
questions:
Each of these categories of the data integrity can be enforced by the appropriate
constraints. MySQL supports the following constraints:
PRIMARY KEY , UNIQUE , FOREIGN KEY , CHECK , NOT NULL,
and DEFAULT
A FOREIGN KEY: constraint prevents any actions that would destroy link
between tables with the corresponding data values. A foreign key in one table
points to a primary key in another table. Foreign keys prevent actions that
would leave rows with foreign key values when there are no primary keys with
that value. The foreign key constraints are used to enforce referential integrity.
A CHECK: constraint is used to limit the values that can be placed in a column.
The check constraints are used to enforce domain integrity.
A NOT NULL: constraint enforces that the column will not accept null values.
The not null constraints are used to enforce domain integrity, as the check
constraints.
NOTE: Each column is named for a specific attribute and must contain
contains values for the attribute it represents only. For example,
CUSTOMER_FNAME must contain only customers‟ first name values,
where as a column named CUSTOMER_PHONE must only contain
customers‟ phone number values.