48 users online (0 members and 48 guests)  

Thread: Stuck on mySQL!


  Results 1 to 6 of 6

Related

  1. Stuck in CSS!    Forum: CSS Forum
    Replies: 3
  2. I'm stuck on my website- regarding MP3 downloads    Forum: General Discussion
    Replies: 2
  3. Need help...stuck!!!    Forum: Javascript Forum
    Replies: 3
  1. #1
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Unhappy Stuck on mySQL!

    I want to extend some functionality at work, but my brain's frozen!
    I have a "jobs" table (primary key is 'callref'), and a "customer" table (primary key is 'cust_id'), and, of course, the ability to create others!
    I need to enhance the recording of training jobs, by adding a list of attendees. Each course will have a variable number of attendees. All the attendees will be customers.
    Anybody want to suggest how I get started on this, I'm at a total loss!
    tia
    Last edited by DeadMeatGF; 03-08-2007 at 05:37 PM. Reason: Changed Subscription ...

  2. #2
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: Stuck on mySQL!

    I believe all you would need to do is add a third table. Call it 'attendees' or whatever. In it, you would have 'callref' and 'cust id' as data elements that would tie to the other two tables. Does that work for you?
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  3. #3
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: Stuck on mySQL!

    Absolutely - it was just a brain freeze!
    I'd taken too big a step in my first thought, overcomplicated things, and couldn't get back to basics!
    Code:
    +---------+---------+
    | callref | cust_id |
    +---------+---------+
    |       1 | Cust_01 |
    |       1 | Cust_02 |
    |       2 | Cust_01 |
    |       2 | Cust_03 |
    |       2 | Cust_07 |
    +---------+---------+
    That kind of thing, I believe!
    Cheers!

  4. #4
    Zoup's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    8

    Re: Stuck on mySQL!

    Code:
    +---------+---------+
    | callref | cust_id |
    +---------+---------+
    |       1 | Cust_01 |
    |       1 | Cust_02 |
    |       2 | Cust_01 |
    |       2 | Cust_03 |
    |       2 | Cust_07 |
    +---------+---------+
    not to be picky but you are wasting a ton of space in your cust_id and attendees table having the prefix cust_ before the identifier.

  5. #5
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: Stuck on mySQL!

    Quote Originally Posted by Zoup View Post
    not to be picky but you are wasting a ton of space in your cust_id and attendees table having the prefix cust_ before the identifier.
    It depends on your database schema. You could have multiple foreign keys in any table, which would make the cust_ prefix not only desirable but mandatory, or at least the preferred method of distinguishing one id from another.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  6. #6
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: Stuck on mySQL!

    It's to match with the other table it links to, as I'm not the only one developing this, and matching the names makes handovers quicker.
    As for the original name, I'm extending an exisiting system so I have no control over those - but I think they were named in that manner for similar reasons.

    Fair point, though.
    I remember having to squeeze every spare bit out of a system to make it fit, back in the "old days"



Tags for this Thread