Professional Documents
Culture Documents
DBMS Terminologies:
Case Study of MySQL: Before we proceed to explain MySQL database system,
let's revise few definitions related to database.
Column: One column (data element) contains data of one and the same
kind, for example the column postcode.
Primary Key: A primary key is unique. A key value cannot 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.
MySQL
MySQL is a fast, easy-to-use RDBMS being used for many small and big
businesses. MySQL is becoming so popular because of many good reasons:
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.
Functions
In SQL databases, a user-defined function provides a mechanism for extending
the functionality of the database server by adding a function that canbe evaluated
in SQL statements.
Triggers
A database trigger is procedural code that is automatically executed in response
to certain events on a particular table or view in a database. The trigger is mostly
used for keeping the integrity of the information on the database. For example,
when a new record (representing a new worker) added to the employees table,
new records should be created also in the tables of the taxes, vacations, and
salaries.
Age
Ken Waweru
13
Mike Kibet
37
Arnold Kemboi 82
Favorite Color
Field
Names:
Field 1
Field 2
Field 3
Name
Age
Favorite Color
Record 1
Ken Waweru
13
Record 2
Mike Kibet
37
Record 3
Arnold Kemboi 82
The above is the basic premise of a simple database table, even a real one
having millions of records.
POPULATING AND QUERYING DATABASES
After creating your database, inserting tables, you need to populate it. The LOAD
DATA and INSERT statements are useful for this.
Suppose that your table was to hold your pet information. Then the records can
be described as shown here.
name
Fluffy
Claws
Buffy
Fang
Bowser
Chirpy
Whistler
Slim
cat
cat
dog
dog
dog
bird
bird
snake
f
m
f
m
m
f
m
birth
death
1993-02-04
1994-03-17
1989-05-13
1990-08-27
1979-08-31 1995-07-29
1998-09-11
1997-12-09
1996-04-29
Because you are beginning with an empty table, an easy way to populate it is to
create a text file containing a row for each of your animals.
INSERT Statement
The INSERT INTO SELECT statement selects data from one table and inserts it
into an existing table. Any existing rows in the target table are unaffected.
INSERT INTO table2
(column_name(s))
SELECT column_name(s)
FROM table1;
SELECT Statement
The SELECT statement is used to pull information from a table. The general form
of the statement is:
SELECT what_to_select
FROM which_table
Back- Ups
Introduction
It is very important to do backup of your MySql database, you will probably
realize it when it is too late.
A lot of web applications use MySql for storing the content. This can be blogs,
and a lot of other things. When you have all your content as html files on your
web server it is very easy to keep them safe from crashes, you just have a copy
of them on your own PC and then upload them again after the web server is
restored after the crash. All the content in the MySql database must also be
backed up. A lot of web service providers say they do backup of all the files, but
you should never blindly trust them. If you have spent a lot of time making the
content and it is only stored in the Mysql server, you will feel very bad if it gets
lost for ever. Backing it up once every month or so makes sure you never loose
too much of your work in case of a server crash, and it will make you sleep better
at night. It is easy and fast, so there is no reason for not doing it.
2. Make sure that you have selected to export your entire database, and not just
one table. There should be as many tables in the export list as showing under the
database name.
3. Select"SQL"-> for output format, Check "Structure" and "Add
AUTO_INCREMENT" value. Check "Enclose table and field name with
backquotes". Check "DATA", check use "hexadecimal for binary field". Export
type set to "INSERT".
4. Check "Save as file", do not change the file name, use compression if you
want. Then click "GO" to download the backup file.