SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Oct 2003
    Location
    United States
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    When is it used? A row for each field

    I've seen this in Wordpress:

    wp_usermeta
    umeta_id
    user_id
    meta_key
    meta_value

    I see that this setup would allow for a flexible way to add additional fields to users without modifying the table structure itself.

    Is this an ideal way to setup a table for users that may differ in fields if they are a business or individual? Obviously there would be a basic table for the information all users share (like log in information).

    A problem that I see is if I wanted to grab tons of users, it could get a little complicated. At best, I would be able to perform 2 queries, 1 for each table. And then using PHP, join the results together..

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by tmapm View Post
    I see that this setup would allow for a flexible way to add additional fields to users without modifying the table structure itself.
    it does indeed

    this scheme is called EAV (entity-attribute-value) and it is deceptively simple to put information into, but frustratingly, maddeningly complicated to get any meaningful information out of

    the proper way to handle different user columns as between businesses and individuals is with a supertype/subtype structure
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict
    Join Date
    Oct 2003
    Location
    United States
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that's what I've wanted to know. I'll search the forums to read about supertype/subtype structure and get it set up.


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
  •