> I do have this already, so what you are saying is then loop > over a list of number which are related to the second table, > in other words: > > SELECT * > FROM t_records, t_topics > WHERE t_records.ID_record = t_topics.ID_topics > > Right? Even in this case, I would still have a list of > numbers in one field in the t_records tabl to loop through - > the record could be associated with topic a, topic b, topic c, > and so on.
It sounds like what you're trying to model is called a "many-to-many" relationship, in which one record may have many topics, and one topic may belong to many records. In this case, to build your ideal normalized model, you want to have a table for records, one for topics, and one additional table - a linking table. This third table would simply have two fields, both of which together would comprise the primary key: ID_record and ID_topics. You'd relate each of the other two tables to this table, instead of to each other. In this model, you then wouldn't have to loop over the contents of an individual field. You'd get all sorts of other benefits, as well - you could easily ask and answer questions like "what topics does this record have", as well as "what records have this topic". Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists