Page 1 of 1

inherited databases and understanding others logic

Posted: Wed Jan 26, 2005 7:51 am
by Frapster
I have inherited a database and am having to figure out how it's working. An example of the page it produces is here:

http://www.australiangold.com/lamps/lamps.asp

A selection in the first menu produces changes in the second menu. A selection made in the second menu then produces a list of compatible lamps based on the selection in the previous two lists. The purpose of the lamps.asp page is to show a user which lamps are compatible with which other lamps.

My problem is that I need to make sure that I understand how the tables in the database interact so that I may update them appropriately. I've already written my pages to update three tables and the relationship between the first two is very apparent. It's the third table that has me confused. There are three other tables which for all intents and purposes appear to be redundant and not necessary to the system at all which is adding to my confusion. I've assumed that the tables not ending in '2' are not necessary and have therefore focused strictly upon the ones ending in '2' (family2, lamp_type2 and replacement2).

I've written some code that will input data into table 3 and I've been working on a page to try and replicate the behavior of the lamps.asp page above. It can be viewed at http://www.australiangold.com/lampid/create.php . as you can see in that page I'm close - but not quite.

The table structure is as follows with basic info in parenthesis:

Table 1 = family (redundant?)
-id_name
-family_name

Table 2 = family2
- id_name
- family_name (name of lamp)

Table 3 = lamp_type (redundant?)
- id_type
- name
- family

Table 4 = lamp_type2
- id_type
- name (lamp type code)
- family (ties lamp code to name of lamp)

Table 5 = replacement (redundant?)
- id_compatible
- groupid
- familyid
- preferred

Table 6 = replacement2
- id_compatible
- groupid (ties to id_name and name of lamp)
- familyid (ties to id_type and type of lamp)
- preferred (??? not sure what this is for)

Anyway - I can't see how table three is used in such a way that it works with tables 1 and 2. But - as you can see from the link I posted at the top it does.

I don't need anyone to literally code anything for me. What I'm needing is some sort of plain language explanation about what you think is happening. Particularly with table 3. And a push in the right direction to help me make my file 'create.php' actually work.

Would it help if I posted my code for both pages I've linked to above?

Thanks for your help.

Reading the article on Tony Marton's site

Posted: Wed Jan 26, 2005 9:38 am
by Frapster
I remembered a reply to an earlier thread of mine where someone sent me a link to an article by Tony Marston. It's on many to many relationship. I tried to read it that first time and it didn't make much sense to me. Now, a week or more later and tons of effort working on this project, it actually makes more sense.

The article describes a simple solution using multiple forms and a complex solution using a singular form. I really should use the single form/complex solution. Why? Because it's difficult! lol

So I'm looking at this query and I'm now convinced that the reason my form at create.php is not working is because of the query I'm using. I think my system would work just fine if I could build the right SELECT FROM WHERE ORDER statement.

I want to set the appropriate 'family_name'(s) from Table 1 into form three when the groupid field in table 3 equals the field 'family' in table 2. This is of course based upon the selections I make in field1 and field2.

Reading this article is helping me and confusing me. I know it should work but it's not making complete sense to me yet.