Chapter 7:design your Web database
In this chapter, we need-discuss three problems in order-get-into-MySQL specifics in the next chapter:
 ralational Database concepts and terminology (databases related concepts and terminology)
 Web database design
 Web databse Architecture (schema of the database)
The first problem:ralational database concepts
A table should hava a table_name, a number of columns, a number of rows, each col was corresponding to a different piece of Data, each row is corresponding to an individual data.
(a table has table name, column, row, each column corresponds to different data, each row corresponds to a property of the data)
Each column of the table has a unique name and contains different data.
Each column has a associated data type.
Because of this, columns is sometimes called fields or attributes.
(columns are often referred to as "domains" or "properties")
Each row has the same data type and the same attributes.
Because of this, rows is called records or tuples.
(rows are often referred to as "records" or "tuples")
Each row consists of a set of individual values, correspond to columns.
Each value must has the data type specified by its column.
(each row consists of a single value corresponding to each column (where the row and column intersect is the value); Each value must be the same as the data type defined by the column)
Key is a-to-identify each specific data.
The identifying column in a table is called the key or the primary key.
A key can consist of multiple columns.
Databases usually consist of multiple tables and use a key as a reference from one
Table to another.
Schemas mean that, the complete set of the table designs for a database.
Foreign keys represent a relationship between data in both tables.
Relationships can be either one-to-one, one-to-many, or Many-to-many.
The second Problem:web database design
 Think about the real world objects is modeling (considering the true object to model)
 Avoid storing redundant data (avoid duplication)
 Use atomic column values (using atomic column value)
 Choose sensible keys (select meaningful primary key)
 Think about the questions your want to ask the database (we want to solve the problem with this db)
 Avoid designs with many empty attribute s (avoid null values)
The third Problem:web database architecture
 A user ' s web browser issues an HTTP request for A particular Web page.
 The WEB server receives the request, retrieves the file (xxx.php), then passes it to the PHP engine for processing.
 The PHP engine begins parsing the script. PHP opens the connection to the MySQL server and sends on the appropriate query.
 The MySQL server receives the database query and process it, and sends the results back to the PHP engine.
 The PHP engine finishes running the script, which'll usually involve formatting the query results nicely in HTML. It then returns the resulting HTML to the WEB server.
 The WEB server passes the HTML back to the browser.
A simple summary of designing a Web database