Web uygulaması birden alanlar için arama stratejisi

0 Cevap php

Gelişiminde bir web uygulaması var; gereksinimi katıldı tablolardan ana tabloda önemli alanları artı PK / FK ile ilgili diğer alanları arar tek bir arama alanı sağlamak için

Şema böyle bir şey gider

PROJECTS
projectID
projectTitle
projectTown
projectCountryID (FK to countries table)
agencyID (FK to agencies table)

COUNTRIES
countryID
countryName

AGENCIES
agencyID
agencyName

TAGS_PROJECTS (many-many relationship between tags and projects)
id
projectID
tagID

TAGS
tagID
tagName

Yani, kullanıcı bir arama terimi girin ve biz bunu bir projeye atanan herhangi etiketleri için projects.projectTitle, projects.projectTown, countries.countryName, agencies.agencyName veya tags.tagName içinde oluşursa görmek istiyorum

Dataset projeler tablodaki 10.000-50.000 satır sırasına olmak zamanla büyür ve diğer tablolardaki 000 adlı edecek

Ben bir test düzeneği kurmak ve farklı yaklaşımların testleri çalıştırmak için gidiyorum, ama herkes daha önce benzer bir durumla ele ve sunmak için herhangi bir tavsiye vardı merak ettim?

Ben düşünüyorum ve test edecek olası yaklaşımlar vardır:

SINGLE QUERY I imagine it will be possible to write a single SQL query to do the search, but such a query would probably perform poorly without careful optimisation once the data has grown to its full size. Trouble is I won't be involved after project launch, and so won't have full, real data to experiment with

MULTIPLE QUERIES Because the site and DB will be lightly loaded, a few small queries will probably be at least as quick and simpler to code for. Would issue several SQL queries and then merge the resultsets in PHP for each search.

REDUNDANT SEARCH TABLE I was considering writing a row into another table as a handmade index whenever the project is edited - this would take the text values from the related fields for tags, country, agency, etc, concatenate them into a string and stick it into a search table with the projectID; there would be one row in the project table for each project, essentially representing a denormalised view of the key data that we can search.

Ben MySQL biraz hit kullanarak içine baktım, ama bu üzerinde indeksleme eksikliği sinir duyuyorum ettik; en azından gereksiz arama tablo dikkatle endeksli olabilir

El Teknolojileri - PHP 5.1.6 ve MySQL 5.0.22 RHEL5 üzerinde çalışan

Herhangi bir düşünce, tavsiye veya savaş hikayeleri hoş geldiniz

Zaman ayırdığınız için teşekkürler

Ian

0 Cevap