Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2012
    Posts
    1

    Exclamation Unanswered: Do I need a third table?

    Hello,

    I'm currently designing a MySQL database which will need to accomodate users and authentication. I currently have two tables, Users and Sessions. Having logged in, a new session will be created for the user and inserted into the database.

    users
    ------
    user_id
    first_name
    last_name
    username
    email
    passowrd

    sessions
    --------
    session_id
    user_id
    ip_address
    user_agent
    created_at
    updated_at

    Should I have a third table, called sessions_users to accomodate the relationship.

    sessions_users
    --------------
    session_id
    user_id

    While it is a many to one relationship, many sessions can belong to a single user, but a single session cannot have many users, is this table necessary to conform to the third normal form?

    Thank you!

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    many sessions can belong to a single user, but a single session cannot have many users
    Doesn't sound like a M:M relationship to me..?
    George
    Home | Blog

Tags for this Thread

Posting Permissions

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