Database management systems are widely used in businesses, educational institutions and other organizations to manage the information critical to their operations. Today many databases are used on the world wide web to make information available to millions of web users at the click of a mouse. Examples include online stores, government information sites, and the personal information stored by your school, employer or university.
Many of the online database systems used today share two traits in common: they are relational databases and they use some variant of a common query language called SQL (Structured Query Language) to access and manage the data they contain.
For a simple introduction to these concepts, look at the following links to a very concise tutorial on databases at Macromedia's web site:
What is a relational database?
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/db_basi3.htm
Understanding relational databases.
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/db_basi4.htm
About SQL.
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/db_basi5.htm
Most important SQL language elements.
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/db_basi6.htm
Basic SQL syntax (SQL is case-insensitive, but language elements are shown in ALL CAPS by convention, to differentiate them from the variable data.)
SELECT fields FROM tableName WHERE field=value;
INSERT INTO tableName (field1, field2, field3, etc) VALUES (value1, value2, value3, etc);
UPDATE tableName SET field1=value1,field2=value2,etc WHERE field=value;
DELETE from tableName WHERE field=value;
II. Look at the chum381 database that has been set up for you to practice on.
Look at mysql in terminal (/Applications/Utilities/Terminal)
- log in to the server that hosts the database:
ssh chum310@hummac.byu.edu
enter the chum310 password when prompted (Type 'yes' if asked a yes/no question here.)
- Load the MySQL program:
mysql -p(Type the password when prompted.)
- Once you've entered the mysql program, select the correct database (the semicolon is required):
show databases;(list the available databases)
- Select the database you want:
use chum381db;
- Let's see what tables are in this database:
show tables;
- Look at how a table is structured:
describe people;
- Now you can use any of the commands above to query (lookup data) in the database, insert records in the database, or update data in existing records.
Practice using SQL commands in the chum381db database
AFTER THE EXERCISE...
While a MySQL database can be managed this way, it becomes tedious and cumbersome as the database grows larger. Fortunately there are a number of graphical interfaces for MySQL. One of the best is phpMyAdmin, web-based graphical interface to MySQL databases that allows us to visualize the data in a much more user-friendly format.
To see the database in phpMyAdmin:
Open a web browser and type in the address field:
http://hummac.byu.edu/phpmyadmin
Supply the chum310 user name and password when prompted.
On the left-hand column, choose chum381db from the popup list of databases. You'll see a list of all of the tables in the database. Notice that for each table you can browse, select (query), insert, etc. This interface simply implements the SQL commands using point-and-click instead of entering commands in a command line. Notice that you can even enter SQL statements if you choose, by clicking the SQL tab.