TAILIEUCHUNG - Học php, mysql và javascript - p 24

Bạn thấy đấy, nếu bạn có dữ liệu trùng lặp trên các bảng của bạn, bạn có thể làm giảm đáng kể số lượng yêu cầu bổ sung cần được thực hiện, bởi vì hầu hết các dữ liệu bạn muốn có sẵn trong mỗi bảng. | between them. In fact I would go so far as to say you should denormalize any commonly looked-up data as much as you can. You see if you have data duplicated across your tables you can substantially reduce the number of additional requests that need to be made because most of the data you want is available in each table. This means that you can simply add an extra column to a query and that field will be available for all matching results. Of course you have to deal with the downsides previously mentioned such as using up large amounts of disk space and ensuring that you update every single duplicate copy of data when one of them needs modifying. Multiple updates can be computerized though. MySQL provides a feature called triggers that make automatic changes to the database in response to changes you make. Triggers are however beyond the scope of this book. Another way to propagate redundant data is to set up a PHP program to run regularly and keep all copies in sync. The program reads changes from a master table and updates all the others. You ll see how to access MySQL from PHP in the next chapter. However until you are very experienced with MySQL I recommend you fully normalize all your tables as this will instill the habit and put you in good stead. Only when you actually start to see MySQL logjams should you consider looking at denormalization. Relationships MySQL is called a relational database management system because its tables store not only data but the relationships among the data. There are three categories of relationships. One-to-One A one-to-one relationship is like a traditional marriage each item has a relationship to only one item of the other type. This is surprisingly rare. For instance an author can write multiple books a book can have multiple authors and even an address can be associated with multiple customers. Perhaps the best example in this chapter so far of a one-to-one relationship is the relationship between the name of a state and its

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.