Microsoft Word - Sam's Teach Yourself MySQL in 21 Days - SAMS.doc

(singke) #1
variable and fixed length. You learned the advantages and disadvantages of both of these. You also
looked at the SET and ENUM types, and saw the difference between these two types and how they were
better than ordinary string types. Finally, you read about some of the column modifiers and how they
affect the column in which they are used.

Q&A


Q:

I want to sort the values of my ENUM and SET columns. How do I do
this?
A:
The sort order depends on the order in which the values were inserted.
ENUM and SET types are not case sensitive. The value that is inserted
reverts to the value that you used when you created the ENUM or SET. For
example, if you declared an ENUM with the values "BLACK", "GREEN",
"RED", and inserted a row with the value red, it would be converted and
stored as "RED".
Q: I want to store images in my database. What is the best way to do this?
A:
There have been great debates in the discussion groups about this. One
argument against storing images or large files within MySQL is that MySQL
uses the file system to store its data. Why not let the file system also store
the image files and just store the path to the image? That way you don't
have to worry about fragmentation inside your database. The problem with
this is that if you are operating remotely, you must find some other way of
getting the file over to the remote system. There are both pros and cons to
both sides of this argument. I will cover how to do this both ways when we
get into Interfaces on Days 12 , 13 , 14 and 15.

Exercises



  1. Using the knowledge you have gained here, go back and redefine all the column
    values of the Meet_A_Geek project.

  2. Practice inserting rows into a table using the SET and ENUM column types.


Week 1 in Review


At the end of this week, you should feel pretty comfortable working with the MySQL monitor. You also should
have a firm understanding of database design. Additionally, you should know how to create a relational
database with the proper data types.


Week 2: At a Glance


Day List


Day 8: Populating the Database
Day 9: Querying the Database
Day 10: Letting MySQL Do the Work—Intrinsic Functions
Day 11: MySQL Table Locks and Assorted Keys
Day 12: How to Get Data—Database Interface
Day 13: How to Use MyODBC
Day 14: The Perl Database interface

You should feel really comfortable working inside MySQL. There are no GUIs to learn—just simple
commands. You should also have created a database. You will build on this sample database through each
of these lessons.


Where You're Going


This week keeps up the fast pace by introducing you to the various ways to use MySQL. This week also
builds on your first week by working with the database you created.
In this week's lessons, the focus is on how to use the database. The week will begin by teaching you
how to populate your database with existing data or by transferring data from one database to another.
Day 9 covers the SQL programming language. In this lesson, you'll learn how to "talk" to your database.
Day 10, "Letting MySQL Do the Work—Intrinsic Functions," you'll learn about the functions that MySQL

Free download pdf