Results 1 to 4 of 4

Thread: parent/child table or not?

  1. #1
    Join Date
    Jun 2013
    Posts
    3

    parent/child table or not?

    hi

    i don't know if i should use a parent/child relation.

    i would like to manage ADVERTISEMENT and it's answer...

    so i could something like

    Code:
    CREATE TABLE ADVERTISEMENT(
      ADVERTISEMENT_ID INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
      TITLE VARCHAR(64) NOT NULL,
      DESCRIPTION VARCHAR(400) NOT NULL,
      STATE_ID  INT NOT NULL
      DATE_CREATION DATE,
      USERS_ID INT
    );
    
    CREATE TABLE ANSWER(
      ANSWER_ID INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
      TEXT VARCHAR(400) NOT NULL,
      DATE_CREATION DATE,
      PARENT_ID INT,
      USERS_ID INT
    );
    i will use all field...

    or i can use same table like

    Code:
    CREATE TABLE ADVERTISEMENT(
      ADVERTISEMENT_ID INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
      TITLE VARCHAR(64) NOT NULL,
      DESCRIPTION VARCHAR(400) NOT NULL,
      STATE_ID  INT NOT NULL
      DATE_CREATION DATE,
      USERS_ID INT,
      PARENT_ID INT
    );
    any suggestion?

    thanks

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Your second choice does not have all the fields from two tables from first choice, so I am not sure how you can capture all the information in second option.

    Is one advertisement supposed to have multiple answers?. If yes, then you should use two tables.

  3. #3
    Join Date
    Jun 2013
    Posts
    3
    with second option, some fields are useless (title when a user reply to ads...), table it's like ads/answer...


    in fact

    a user publish a ads and other user replie to him privately

    example

    paul publish an adm

    bob reply to this ads
    paul reply to bob
    bob reply to paul
    ...
    ...

    mathew reply to this ads
    paul reply to mathew
    mathew replty to paul
    ...

    on web page,
    paul can see all discution by user...
    but users see only their discussions

  4. #4
    Join Date
    Jun 2013
    Posts
    3
    any solution?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •