Docsity

Database Management Systems: A Focus on MySQL, Essays (university) of Database Management Systems (DBMS)

Toggle sidebar
bg1
DATABASES MANAGEMENT SYSTEMS (DBMS) DOCUMENT NOTES
Author: Mary Waswa-Wilson
Date: 5th June 2013
Database Management Systems (DBMS)
Objectives
1) To define Database Management Systems (DBMS)
2) To understand and define various terms and basic functionalities of
phpmyadmin interface
3) Learn to install, configure a MySQL database
4) To create users on MySQL
5) To be able to list databases and creating tables
6) To populate and query databases
By the end of the module, participants should be able to:-
1. Design a simple database with 3rd level normalization
2. Install a MySQL server using Xampp
3. Login to MySQL Server and implement the database designed above
4. Populate and query the database using different means: Phpmyadmin,
command line
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Database Management Systems: A Focus on MySQL and more Essays (university) Database Management Systems (DBMS) in PDF only on Docsity!

DATABASES MANAGEMENT SYSTEMS (DBMS) DOCUMENT NOTES

Author: Mary Waswa-Wilson Date: 5 th^ June 2013

Database Management Systems (DBMS)

Objectives

  1. To define Database Management Systems (DBMS)
  2. To understand and define various terms and basic functionalities of phpmyadmin interface
  3. Learn to install, configure a MySQL database
  4. To create users on MySQL
  5. To be able to list databases and creating tables
  6. To populate and query databases

By the end of the module, participants should be able to:-

  1. Design a simple database with 3rd^ level normalization
  2. Install a MySQL server using Xampp
  3. Login to MySQL Server and implement the database designed above
  4. Populate and query the database using different means: Phpmyadmin, command line

DATABASE MANAGEMENT SYSTEMS (DBMS)

What is a Database? A database is an integrated collection of logically related records or files consolidated into a common pool that provides data for one or more multiple uses. You can think of a database as an electronic filing system. A Database Management System (DBMS) Software that organizes the storage of data. A DBMS controls the creation, maintenance, and use of the database storage structures of organizations and of their end users. In large organizations this task is being manned by a Database Administrator Database management systems are usually categorized according to the database model that they support, such as the network, relational or object model. The model tends to determine the query languages that are available to access the database. One commonly used query language for the relational database is SQL, Database management systems range from all systems that run on personal computers to huge systems that run on mainframes. After storage a DBMS needs an application that can enable us access, modify the information in a contextual manner. Examples of database applications may include:

  • Computerized library systems - Koha
  • Automated teller machines (ATM)
  • Flight reservation systems
  • Computerized parts inventory systems Database Management System (DBMS) There are several Database Management Systems (DBMS), such as: F 0B 7 Microsoft SQL Server F 0B 7 Oracle F 0B 7 Sybase F 0B 7 DBase F 0B 7 Microsoft Access F 0B 7 MySQL from Sun Microsystems (Oracle)

DBMS Terminologies:

Case Study of MySQL: Before we proceed to explain MySQL database system, let's revise few definitions related to database.

  • Database: A database is a collection of tables, with related data.
  • 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.
  • (^) Redundancy: Storing data twice, redundantly to make the system faster.
  • 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.
  • Compound Key: A compound key (composite key) is a key that consists of multiple columns, because one column is not sufficiently unique.
  • Index: An index in a database resembles an index at the back of a book.
  • Referential Integrity: Referential Integrity makes sure that a foreign key value always points to an existing row.

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 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 uses a standard form of the well-known SQL data language.
  • 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.

Exercise One: on Practice

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.

THE PHPMYADMIN COMMAND

Working with databases can be a complex and confusing process. Fortunately PhpMyAdmin provides an easy to use and easy to understand interface to administer your database(s). It was intended to handle the administration of MySQL via a web browser. PhpMyAdmin supports a wide range of operations with MySQL. The most frequently used operations are supported by the user interface (managing databases, tables, fields, relations, indexes, users, permissions, etc), while you still have the ability to directly execute SQL statements.

Figure : phMyadmin interface

Understanding Tabs in the Interface Structure: Lists the structor of the databases SQL: Run SQL query/queries on database mysql: Search: Search in database Query: Used to write queries and vuews from table Export: View dump (schema) of database, Export Import: introduce/ import a file Operations: Basic Operations within the database Privileges: Accessing database and user scope to manipulate the database Drop: Used to delete a database or table Database tables Listing and creating database tables

  • At its simplest, a database will consist of tables like this:

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 table (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 WHERE conditions_to_satisfy; what_to_select Indicates what you want to see. This can be a list of columns, or *****^ to indicate “all columns.” which_table indicates the table from which you want to retrieve data. The WHERE^ clause is optional. If it is present,^ conditions_to_satisfy^ specifies one or more conditions that rows must satisfy to qualify for retrieval.

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.

Backup of Mysql database Open phpMyAdmin.

  1. Click Export in the Menu to get to where you can backup you MySql database.
  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.

Restoring a backup of a MySql database

  1. To restore a database, you click the SQL tab.
  2. On the "SQL"-page , unclick the show query here again.