Howdy, and thanks in advance for any assistance.

I have some content for the web which is in part repeating sections, so I am going to store the individual text components of each repeated section in the fields of a record, so I can control the section's HTML formatting completely. I could be wrong, but to me it seemed like it was begging for a database back-end. So for the most part I am set to go.

However, one portion of each repeated section has within itself a structure that implies a table with records. It is citations within parenthesis, and each citation has two parts: italic name, and non-italic citation source information. Each repeating section (or record) of the page may have within itself from one to umpteen individual, two-part citations. Now, if the citations were only ONE font face, I would not have a problem. But since each citation has an ITALIC part and a regular part, I am faced with an interesting question about database structure.

Is it possible for me to "nest" tables within a relational database? My hunch is no. If I could somehow send, via HTML form, the information for each standard record PLUS the two-part citation material for its own little table ASSOCIATED with that specific record, then I might have the problem licked.

Is this making any sense to anyone? In summary, I want to know if it is possible to make nested tables, or is there another way around this problem?

By the way, are there standard recommendations on how many tables a database should have maximum? I'm just curious, being somewhat new to RD's.

Thanks for any ideas.

    can't nest tables in DB

    but store the italic name and the source in different fields...you can combine these into one cell on a table in the html but this way you can set the font for each one

    <td><i>$name</i>$source</td>

    and bob's your uncle....

    as to limits on tables

    it is more a limit on size available for the DB as a whole...the bigger it gets, the more likely you are to need a fullscale DB like oracle or sql server....

    hth
    bastien

      OK, I hear you, but consider this: each record of the dynamic-content page may have anywhere from 1 to 10 individual, two-part citations.

      So having said that, if I stick them all in the same table and write a print loop until EOF kinda thing, how do I ensure that each record of prints ONLY the two-part citations associated with that record?

      Each overall record is like this:

      (Headline Name)
      (Body text body text body text body text body text body text)
      (Citation name (Italic))(Citation src(nonitalic))

      BUT, as you see each citation is comprised of two parts, an italic and a nonitalic. And, each overall record may have umpteen citations. Do you see how this has me stymied?

      BTW, I appreciate the assistance.

        Create two tables which are related by a one-to-many relationship (ie each record in the master table can be linked to one or more records in the detail table):

        / everything except citatons in here /

        create table tblMaster(
        intKey int not null auto_increment,
        vcrDescription varchar(100) null,
        /
        other fields
        /
        primary key(intKey)
        );

        / citations and link to master in here /

        create table tblDetail(
        intKey int not null auto_increment,
        intMasterKey int not null,
        vcrCitationName varchar(100) null,
        vcrCitationSource varchar(100) null,
        primary key(intKey)
        );

        Combine with SQL:

        select *
        from tblMaster m
        (inner join tblDetail d
        on e.intKey = intMasterKey)

          Thanks for the help, Gary!

          OK, I think I see where you're going with this, but being a php/MySQL newbie, I'm having a little trouble making sense of your last SQL statement. I've gone and run the definition language you provided, and have created the appropriate tables and fields; is the last statement for inclusion on the dynamic-content page, for joining the data?

          If you could explain in more detail, I'd be grateful. Specifically, I would like to know how each record from the master table knows WHICH records from the detail table to associate with. That is a question I must be able to answer when I create the form-entry page for appending records to the database, because as of this moment I don't have a clue how to do that with the one-to-many relationship! LOL.

          THanks gain in advance-

            Each record in the master table has a unique identifier - the "primary key". This is stored in the field "intKey" in my example.

            Each record in the detail table also has a unique identifier - again called "intKey" in my example - but of course you could call it something else.

            As well as this, the detail table also stores the primary key of the master record to which it relates. That's how you are able to link the tables in SQL (the "inner join" bit).

            The data in the tables looks like this:

            Master table:

            intKey vcrDescription ...

            1 "some data"
            2 "some other data"
            3 "yet more data"

            Detail table:

            intKey intMasterKey ...

            1 2 (relates to master record 2)
            2 2 (relates to master record 2)
            3 1 (relates to master record 1)
            4 3 (relates to master record 3)

            You get the idea? (This is what is meant by a "relational" database.)

            In PHP you need to call the "mysql_query" function, passing in the SQL statement I gave you and then dynamically create you HTML.

            You'll need to refer to the manual I'm afraid for that!

              OK, I'm still somewhat lost but far less than when I started. Thanks a bunch for the assistance, I am making progress bit by bit...

                I have a similar situation - a one to many relationship and I am trying to figure out how to update both tables via an HTML form but I am having trouble. I am hoping you can help me. How do I run an insert query into the first table and then retrieve the id (auto_incremented, unique id) so that I can use it for the second insert query? Thanks - Lori

                  I finally got it - mysql_insert_id() which I had tried unsucessfully before because I was trying to insert and then do a select which I see is not necessary. Lori

                    Hey Lori if I could steal some of your code (the parts for updating two tables from one form) I would favor thee with 600 golden ducats. Seriously though I would really be grateful; I am a Nu-B and I am not having luck today. Thanks-

                      Write a Reply...