Home > Backend Development > PHP Tutorial > Database design skills 1_PHP tutorial

Database design skills 1_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:26:07
Original
828 people have browsed it

In the design of dynamic websites, the importance of database design is self-evident. If it is not designed properly, it will be very difficult to query and the performance of the program will also be affected. Regardless of
whether you are using mySQL or Oracle database, formalized table design can make your PHP code more readable and easier to expand, which
will also improve application performance.
Simply put, formalization is to eliminate redundancy and uncoordinated subordination in table design. In this article, I'll walk through five progressive processes to teach you the formalization techniques you should know in your design. Thereby establishing a feasible and
efficient database. This article will also analyze in detail the types of relationships that can be exploited.
It is assumed here that we want to create a user information table, which stores the user's name, company, company address and some personal favorites or URLs. At the beginning, you might define a table structure as follows:
Zero status form
users
name company company_address url1 url2
Joe ABC 1 Work Lane abc.com xyz.com
 Jill XYZ 1 Job Street abc.com xyz.com
 Since no normalization is performed, we call this form of table a zero-state form table. Pay attention to the url1 and url2 fields---What if we
need a third url in the application? This way you have to add an extra column to the table, which is obviously not a good idea. If you want to create a scalable
system, you should consider using the first normalized form and apply it to the table.
First level normalized form
1. Eliminate duplicate groups in each table
2. Create a separate table for each set of related data
3. Use a primary key to identify each set Related data
The above table obviously violates the first rule above, so what does the primary key in the third rule mean? Very simple, it just adds a unique, automatically increasing integer value to each record. Through this value, two records with the same name can be distinguished. By applying the first level of normalization, we
get the following table:
users
userId name company company_address url

1 Joe ABC 1 Work Lane abc.com
1 Joe ABC 1 Work Lane xyz.com

2 Jill XYZ 1 Job Street abc.com
2 Jill XYZ 1 Job Street xyz.com
Now our table can be said to be at the first level of formalization Form, it has solved the limitation problem of url field, but this processing has brought
a new problem. Every time we insert a record into the user table, we have to repeat all the company and user data. Not only does this make the database
larger than before, but it is also prone to errors. Therefore, it still needs to go through the second level of formalization.



http://www.bkjia.com/PHPjc/531982.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531982.htmlTechArticleIn the design of dynamic websites, the importance of database design is self-evident. If it is not designed properly, it will be very difficult to query and the performance of the program will also be affected. No matter you are using m...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template