SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Wizard
    Join Date
    May 2002
    Posts
    1,370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    many to many table - timestamp

    On a many to many table/composite primary id, users are inserting from a series of drop menus.

    When the inserts are performed so near together, will the mysql timestamp function discern the actual time difference on this many to many insert? In this case the row order needs to be preseved when the values are being transferred.

  2. #2
    SitePoint Wizard jumpthru's Avatar
    Join Date
    Apr 2000
    Location
    Los Angeles, California
    Posts
    1,008
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by datadriven
    On a many to many table/composite primary id, users are inserting from a series of drop menus.

    When the inserts are performed so near together, will the mysql timestamp function discern the actual time difference on this many to many insert? In this case the row order needs to be preseved when the values are being transferred.
    As long as you do them in the correct order from within your program, then they will stay in the correct order in the table. The timestamp will be down to the second, so its possible that you could have entires with similar stamps.

    If the order of the entires is important why not just create an autoincreasing index field that will give each entry an actual number in the order that its created? This is probably a better option.

  3. #3
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a common mistake to think that SQL table rows are "ordered" or "sorted" in any way. "Table" is really not a "range", but just a "bunch" of records and there is no order unless you specify it in your quiery.

  4. #4
    SitePoint Wizard
    Join Date
    May 2002
    Posts
    1,370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the order of the entires is important why not just create an autoincreasing index field
    By this do you mean auto increment -- I can't its a many-to-many table with composite primary index (those two keys being heavily searched on). If you mean something else I'd sure like to hear about it.

    If by this you mean insert 1 thru 6 in another field just for this, I sure like the way you think!

  5. #5
    SitePoint Wizard jumpthru's Avatar
    Join Date
    Apr 2000
    Location
    Los Angeles, California
    Posts
    1,008
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by datadriven
    By this do you mean auto increment -- I can't its a many-to-many table with composite primary index (those two keys being heavily searched on). If you mean something else I'd sure like to hear about it.

    If by this you mean insert 1 thru 6 in another field just for this, I sure like the way you think!
    You can still have the two fields with the two IDs. Just make a third field that tracks the order.

    Make it auto-increment if you want an overall order for the entire table, or if you only want 1-6, then insert 1-6 when you do your insert.

    In other words, like stereofrog said, dont reply on MySQL to keep track of the order, do it your self manually.


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
  •