★ wanayoo — archive 1999 http://slashcode.com/askslashcode/00/07/26/1733212.shtmlNouvelle recherche | Portail wanayoo
Slashcode
search Slashcode:
 
Slashcode open source project
 
Slashcode
- About
- FAQ
- Topics
- Authors
- Preferences
- Older Stuff
- Submit Story

Andover.Net
AndoverNews
Ask Reggie
DaveCentral
FreeCode
Freshmeat
ITR
MediaBuilder

 
Adding Extra Columns in the Database
posted by pudge on Wednesday July 26, @12:27PM
from the try-and-see-:-) dept.
Slash ttyp0 writes "I'm interested in altering the users table so that I can store the users birthday and gender (for demographic data). Has anyone else tried this? The reason I ask is that I'm unsure of how all the selects work, I don't wont to break the database. Would two extra columns affect the functionality at all?"

<  YASS: Independent Media Center of Philadelphia | PHP & Slash  >

 

 
Slashcode Login
Nickname:

Password:

Related Links
  • Slashcode
  • ttyp0
  • More on Slash
  • Also by pudge
  • 'Adding Extra Columns in the Database' | Login/Create an Account | 6 comments | Search Discussion
    Threshold:
    The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
    mySQL dox (Score:0)
    by Anonymous Coward on Wednesday July 26, @01:53PM EST (#1)
    mysql documentation is awesome, i recommend you look at it. Specifically, read up on 'alter'ing tables: http://www.mysql.com/documentation/mysql/full/
    [ Reply to This | Parent ]
    altering the standard columns (Score:1)
    by tf23 on Wednesday July 26, @02:48PM EST (#2)
    (User #175 Info)
    IMHO: I think you can get away with adding columns to the standard slash tables. The reason that I think this is that some code does sqlSelectMan('*') and others select only the columns that it needs from whichever user datatable it needs to query from. I think the only thing you need to be sure of is that you define DEFAULT values for each column you add.

    Now, with that said, I wouldn't do it the way you are suggesting. Instead, I would create my own table. Call it users_mydata or something. Create a primary key that reflects back to the primary key uid from the users table, and the rest of this new table would be whatever data (sex, bday, etc) that you want held.
    That way, if the schema changes for the default tables for slash, your data is safe and not interfering with any versionversion sql mod scripts when you upgrade your slash version.

    [ Reply to This | Parent ]
    [OT]problem running slash, newbie (Score:0)
    by Anonymous Coward on Wednesday July 26, @10:03PM EST (#3)
    Anyway, I'm getting 500 internal server errors all over the place. I put details on a pollbooth rather than start an OT thread in one of the stories, so if anyone would care to take a moment and help a newbie I'd much appreciate.

    TIA
    [ Reply to This | Parent ]
    Add a new table instead (Score:0)
    by Anonymous Coward on Thursday July 27, @03:53PM EST (#5)
    It would be smarter and easier to upgrade if instead of adding two new columns, you add another table that references the key of the user table (I've never seen the DB so I wouldn't know).
    [ Reply to This | Parent ]
    sql wrapper functions already exist (Score:0)
    by Anonymous Coward on Monday July 31, @01:21PM EST (#6)
    I had the same type of problem to solve. I'm working on a slash site that requires on-line proposals, and they want some sort of grading system, so I also had to add extra datatypes to certain tables. Use the "alter" functionality as suggested. I recently added the ability to post topic descriptions, and if you look inside Slash.pm, there are SQL wrapper functions that let you interact with the database straight from the perl files: sqlInsert,sqlSelect etc. If you need to be able to bring up these extra columns, and display them in an interface like admin.pl, use those wrapper functions. they work like a charm :-)
    [ Reply to This | Parent ]

    You are standing on my toes.

    [ home | contribute story | older articles | about | faq | authors | preferences ]