• Gazareth (9/24/2012)


    Hello,

    I seem to recall from my database design classes a while back, being told that a link table with just a datetime field in wasn't really a link table.

    I've just designed exactly that, but can't see another way?

    Is this true, and what would the alternative be?

    create table sourcefile (sourcefileid int primary key, name varchar(500));

    create table updateserver (updateserverid int primary key, name varchar(500));

    create table sourcefiles_updateserver (sourcefileid int, updateserverid int, updatetime datetime,

    primary key (sourcefileid, updateserverid),

    foreign key (sourcefileid) references sourcefile (sourcefileid),

    foreign key (updateserverid) references updateserver (updateserverid));

    Cheers

    That certainly looks a bit off. Typically this type of junction table is used to handle a many to many relationship. Not sure what you are trying to track here but I don't think this is what you want. Are you trying to audit when a given sourcefile was used to update a specific server? The way you have this coded you can only ever update a specific server with a given sourcefile. If that is what you are after then this is NOT a junction table it is more like an audit table.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/