PHP-Database-Basics-DB-Arrays

Adding MySQL to PHP and combining the applications for your
 dynamic web site is a great start. But, it helps tremendously
 to structure your database right. We'll give you a solid
understanding of both database design and the language that's
 used to communicate with the database, SQL. The first step in
 setting up your database is to design how you'll store your data.
 Then, you'll learn how to add, view, and change data.


Databases are a repository for information.
 They excel at managing and manipulating structured information.
 Structured information is a way to organize related pieces of
 information, which we discussed previously in our chapters on PHP.
 The basic types of structured information,
 which can also be called data structures, include:

Files

Lists

Arrays

Records

Trees

Tables



Each of these basic structures has many variations and allows
 for different operations to be performed on the data. An easy
way to understand this concept is to think of the phone book.
 It's the most widespread database, and it contains several
items of informationname, address, and phone number, as well
 as each phone subscriber in a particular area. Phone books
have evolved, and some people may have bolded names, but for
the most part, each entry in the phone book takes the same form.

If you think of the physical hardcopy phone book in similar
terms as a database, the phone book is a table, which
contains a record for each subscriber. Each subscriber record
 contains three fields also known as columns or

attributes: name, address, and phone number. These records
 are sorted alphabetically by the name field, which is
called the key field.


Adding MySQL to PHP and combining the applications for your
dynamic web site is a great start. But, it helps tremendously
 to structure your database right. We'll give you a solid
 understanding of both database design and the language that's
 used to communicate with the database, SQL. The first step in
 setting up your database is to design how you'll store your
data. Then, you'll learn how to add, view, and change data.

Databases are a repository for information. They excel at managing
 and manipulating structured information. Structured information
 is a way to organize related pieces of information, which we
discussed previously in our chapters on PHP. The basic types of
 structured information, which can also be called data structures
 include:

Files

Lists

Arrays

Records

Trees

Tables

Each of these basic structures has many variations and allows
 for different operations to be performed on the data.

An easy way to understand this concept is to think of the
 phone book. It's the most widespread database, and it
contains several items of informationname, address,
and phone number, as well as each phone subscriber
in a particular area. Phone books have evolved, and some
people may have bolded names, but for the most part,
each entry in the phone book takes the same form.

If you think of the physical hardcopy phone book in
similar terms as a database, the phone book is a table,
 which contains a record for each subscriber.
Each subscriber record contains three fields also known
 as columns or attributes: name, address, and phone number.
 These records are sorted alphabetically by the name field,
 which is called the key field.
Related Posts:
  • LOAD DATA INFILE statement MySQL LOAD DATA INFILE provides an alternative to INSERT for adding new records to a table. With INSERT, you specify data values directly in the INSERT statement. LOAD DATA INFILE reads the values from a separate datafile.The… Read More
  • Table Types-MySQL MyISAM is the default table type in MySQL Version 3.23. It's based on the ISAM code andhas a lot of useful extensions. The index is stored in a le with the .MYI (MYIndex) extension, and the data is storedin a le with the .… Read More
  • Advantages of Using PHP with MySQL Advantages of Using PHP with MySQL   There are several factors that make using PHP and MySQL together a natural choice: PHP and MySQL work well together PHP and MySQL have been developed with each other in … Read More
  • Why MySQL Database? MySQL has its own client interface, allowing you to move data around and change database configuration. Note that you must use a password to log in. Assigning database users allows you to limit access to server tables … Read More
  • Running MySQL on Windows MySQL supports TCP/IP on all Windows platforms and named pipes on NT. The defaultis to use named pipes for local connections on NT and TCP/IP for all other cases if theclient has TCP/IP installed. The host name speci es whic… Read More
  • Managing the Database Creating Users To create users above and beyond the default privileged root user, issue the grant command. The grant command uses this syntax: GRANT PRIVILEGES ON DATABASE.OBJECTS TO'USER'@'HOST' IDENTIFIED BY 'PASSWORD… Read More
  • Basic MySQL Basic MySQL Create or Drop a Database Starting with something simple, you can use the CREATE command to create a new database. The syntax is CREATE DATABASE IF NOT EXISTS [yourDBName]; When you create a database wit… Read More
  • Create the months table With MySQL Create the months table as follows: CREATE TABLE months ( month_id INT NOT NULL AUTO_INCREMENT, month VARCHAR (20), days INT, PRIMARY KEY (month_id));      To add the months to the new table, s… Read More
  • Database Backups using mysqldump The MySQL server, and mysql, the MySQL client, a MySQL installation comes with many useful utility programs. We have seen mysqladmin, which is responsible for the control and retrieval of information about an operati… Read More
  • PHP-Database-Basics-DB-Arrays Adding MySQL to PHP and combining the applications for your dynamic web site is a great start. But, it helps tremendously to structure your database right. We'll give you a solid understanding of both database de… Read More
  • Linking Affects the Speed of MySQL Most of the following tests are done on Linux with the MySQL benchmarks, but they should give some indication for other operating systems and workloads. You get the fastest executable when you link with -static. On Linux, yo… Read More
  • Query Strings Query string data is very easy for the user to alter, because it ’ s visible and editable within the browser ’ s address bar. Therefore, query strings should be used only in situations where sending incorrect data won ’ t co… Read More
  • Backing Up and Restoring Data MySQL Even the best maintained databases occasionally develop problems. Hardware failures, in particular, can really throw a monkey wrench into your web pages. Now that you're using a database, just backing up the files (HTM… Read More
  • Advanced SQL Many of the features shown in this chapter are specific to MySQL's version of SQL. For example, MySQL's functions are useful tools for working with strings, dates and times, and math. Also, we'll show some w… Read More
  • mysql_query-executes query mysql_query function  executes query on the default database, set using mysql_select_db() or by a previous query using mysql_db_query(), on the MySQL server connection referenced by connection . If no connection … Read More