MYSQL
What
Is a Database?
A database is a
collection of data. Databases implemented through a computer are created within
software. That software, commonly known as a database application, controls
how. RDBMS, which is an acronym for relational database management system.
Database servers usually have one or more distinct APIs for programmatically
creating, accessing,
Managing,
searching, and replicating the data they hold. It is through the API that you
connect to and work with data stored in database servers when using PHP. There
is no requirement that an RDBMS be used to store data. Other data stores can be
used such as a flat file or a table known as a hash table. These are perfectly
fine for some applications, especially smaller applications; however, for
larger applications or applications that require optimal speed for large data
stores, an RDBMS is a requirement.
PHP-Supported
Databases
PHP
Data Objects (PDO) was introduced back with the 5.1 release of PHP. PDO creates
a consistent, abstracted interface to database servers and data. PHP offers
several database-specific drivers for both PDO and non-PDO access. The PHP web
site contains a list with the latest information about databases that can be
integrated along with the PDO abstraction layer and other abstraction layers.
MySQL, is an incredibly popular and powerful RDBMS. MySQL provides one of the
letters in the ubiquitous كل الوجودacronym
اللفظة الاوائلية“LAMP,”
which is an abbreviation for Linux, Apache, MySQL, PHP/Perl/Python. MySQL has
become so popular for several reasons. 1- MySQL is free, 2- MySQL is also
stable, meaning that it’s not prone عرضةto crashing even under load.3- MySQL is lightweight, meaning
that it doesn’t require many resources to install or run.4- MySQL is fast and
easy to use. 5-MySQL is powerful, with all of the features required for web
applications. MySQL AB, which is the company behind MySQL (owned by Sun),
changed the licensing for MySQL relatively recently. In the latest iteration as
of this writing, MySQL offers a product called MySQL Server Community Edition,
which is essentially the same as the MySQL Enterprise Server, but is lacking
official MySQL support and some graphical user interface (GUI) tools. If your
organization needs an officially supported product, where you can call for
assistance with the database server at any time, then MySQL Enterprise
is for you. MySQL AB’s support is excellent; it’s not unheard of to get
responses from developers themselves. Otherwise, the MySQL Server Community
Edition is your choice. I’ll be concentrating on the MySQL Server Community
Edition in this book.
Summary
The
great advantage of the Web is its capability to make large quantities of
information publicly
available
quickly and cheaply. This functionality has been tremendously بشكل مروع enhanced by the recent
increase
in availability of inexpensive, reliable databases. PHP supports several types
of databases, including flat-file, hash, and relational databases. Most
large
web sites (and even small sites, too) use some sort of relational database
management system
(RDBMS).
MySQL is a common choice among PHP developers. MySQL is not only free but also
lightweight, stable, and full of features necessary for both online and offline
applications.
Relational
Databases and SQL
SQL is
the language of relational databases. A simple query like a one-table SELECT will be
more or less the same whether you’re using a tiny database like mSQL or an
expensive like Oracle. The big advantage for you, the web developer, is that,
after you learn SQL, you will be able to interact with numerous databases
across all platforms without a steep retraining curve. Just imagine how horrible
life would be if Oracle, MySQL, and SQL Server all had entirely different sets
of commands
for
putting data in and getting data out of their stores — as if Oracle used SELECT to ask
for data sets, MySQL used VALJ
(the developers are Swedish, you know), and
SQL Server used FIND IT IN
THIS TABLE (to better match the vocabulary of
Windows). SQL is the common vocabulary and syntax that will save you from this nightmare.
There are differences among products, and in their implementations of the SQL
standard and the extensions they each define to that standard, but it’s better
to have 80 percent in common and 20 percent different than the other way
around.
The
Workhorses of SQL
data
manipulation statements are supported by
every SQL server and will constitute an
extremely
high percentage of all the things you’ll want to do with a relational database.
These four
horsemen
of the database are SELECT, INSERT, UPDATE, and DELETE. These commands are your friends and helpmates; get comfy with
them, and they will serve you well. The thing to remember about these four SQL statements is that
they manipulate only database values, not the structure of the database itself. In other words, you
can use these commands to add data but not to make a database; you can get rid
of every piece of data in a database, but the shell will still be there — so,
for instance, you wouldn’t be able to name another database on the same server
with the same name. If you want to add or get rid of columns, blow away entire
databases as if they never existed, or make up new databases, you need to use
other commands such as DROP, ALTER, and CREATE.
SQL queries are usually quite whitespace insensitive
Joins
Joins
are one of the main useful features of SQL.
A SELECT statement
on a single table without joins might be visualized as being something like a row
in a spreadsheet. But an SQL database is by definition relational. To
understand the philosophy behind the relational database concept, you have to
think back to some occasion on which you were forced to fill out a whole bunch
of forms — such as applying for a loan, visiting a doctor’s office for the
first time, or dealing with some kind of governmental formality. (If you’ve
never had this experience, it’s because you’re young enough to have lived entirely
in a world of relational databases.) As you were writing down your name,
address, phone, and Social Security number for the 15th time you probably
thought, “Why can’t I just write my address down once, and then they could just
look it up on a need-to-know basis?” That’s exactly the concept behind a
relational database.the way a relational database differs from paper forms is
the main identifier. Humans do well with text and prefer to categorize by
textual identifiers such as names. If a dentist’s office or auto body shop
stored its paper files in numerical order, it would be difficult for anyone to
lay his hands on John Johnson’s forms when John next required service. Frankly,
most paper file users these days ask for your Social Security number as a backup
— it works solely to differentiate you from other people in their files with
exactly the same first, last, and middle names. Databases, on the other hand,
work well with integers. You’ll frequently use integer values to create unique
identifiers or IDs within a database table. This field or column is then called
a primary key, which indicates that each value in that column will be unique
and that the rows within that column will always have a value in the primary
key field. Because primary keys are unique by nature, a database needs only one
to identify a person, place, or thing uniquely — no matter how many tables refer
to that piece of information. So instead of needing to repeat information
several times, like this:Name: John
Johnson
SS#:
123-45-6789
Name:
John Johnson
Fears:
Cats, Friday the 13th, Flying
Name:
Jane Jones
SS#:
987-65-4321
Name:
Jane Jones
Fears:
Heights, Flying
with a
relational database you can write down each piece of information just once and
then relate it to each other piece using integers, as shown in Tables 13-1 to
13-3.
This is clearly a
neater and faster (for a database) way to store this information. But when you
need
to pull out the
data into a human-readable form, there’s a problem: You have to get and correlate
information from
more than one database. That’s the job of a join.
No comments:
Post a Comment