SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict marylin77's Avatar
    Join Date
    Aug 2003
    Location
    Spain
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    one to many relationship database

    In Kevin Yank's book "Build your own database driven your website using php and mysql" (2nd edition) the author explains one to many relationship database with the example one author/many email addresses in page 93.
    He advices never overload a table field to store multiple values...so he solves it with two separate tables:
    1-Table authors with the fields: id and name.
    2-Table emails with the fields: id email and aid.
    aid is a number which coincide with id number in order to match both them.
    well...I have thought other solution and i“d like to know if i am wrong or not.
    My solution:
    1-A unique table called details with fields: id mail and name.
    Example of stored rows in my solution:
    row1:
    id=1 mail=blabla@hotmail.com name=Maria Smith
    row2:
    id=2 mail=frer@terra.es name=Maria Smith
    row 3:
    id=3 mail=gret@ono.com name=Marķa Smith
    As we see...this solution does not overload a table field...only repeats...XDD
    Is it possible this solution?
    Regards from Spain.

  2. #2
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, this is just not considered efficient since you are storing the name "Maria Smith" many times in many rows. It would work but it would be much faster to simply store the name Maria Smith in one table and then refer to her id in the other table...
    - website


Bookmarks

Posting Permissions

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