Q&A
Q:
Is there any other way to enter commands into mysql? The MySQL
monitor can be a little cumbersome, and I have a ton of commands to
enter.
A:
There is another way, if you are using a UNIX machine. You can pipe a file
into the mysql program. For example, create a file using your favorite editor
(emacs, vi, or gedit). Name the file anything you want. Your commands
should appear as they do within the monitor. Make sure they are terminated
by a semicolon or an escaped \g. When you are finished, you can import
the file into MySQL. Make sure the daemon is running and that you are in
the mysql directory. Type the following:
cat /fullpath/filename |bin/mysql
This will execute all the statements within the file. This is a great way of
adding data or creating a database schema. This also creates a way of
storing the schema for transport or for recreating the database if you
lose a disk.
Q: How many databases can one MySQL RDBMS contain?
A:
Because MySQL uses the file system of the operating system, there really is
no limit to the number of databases contained within a single MySQL
RDBMS. The size of the database is limited by the operating system. The
database tables can only be as big as the OS's file system will allow. For
Linux, the maximum size is 4GB.
Exercises
- Create and drop databases using the mysqladmin utility and by using the monitor.
- Add a couple of users to the database, and try using these accounts.
Day 5: Making Your Data Normal
Overview
When structuring a database, putting the right columns in the right tables can be a daunting task. When you
finally accomplish this task, you may find out that you have logic problems within your database, especially if
you come from the old world of non-relational databases where everything was contained in the same file.
Using the old idea of keeping all your data together in one table in a relational databases is a bad idea. It's
almost sacrilegious. A set of rules was established to help database designers. These guidelines lead to the
design of truly relational databases without logic flaws. Applying these rules to your database structure is
referred to as normalizing your data, normalization.
Today, you will learn
What normalization is and the benefits it can provide
The degrees of normalization
What Is Normalization?
Normalization is a set of rules to help database designers develop a schema that minimizes logic problems.
Each rule builds on the previous rule. Normalization was adapted because the old style of putting all the data
in one place, such as a file or database table, was inefficient and led to logic errors when trying to
manipulate the contained data. For example, look at the Meet_A_Geek database. If you stored all the data
in the Customers table, the table would look like something like the following:
Customers
Customer_ID
Last_Name
First_Name
Address
Product_Name1
Product_Cost1
Product_Picture1