Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004

    Unanswered: Is primary key really imp when theres no relation with other TBL

    Does it make sense if i design a table with 2 columns with out defining any key?
    username varchar(64) notnull and password varchar(64) notnull
    This table does'nt have relation with any other table, shld we really have an id field???
    lets say if i compare the username and password entered by the user against the values stored in the table by using the following prepared statements, will it have any disadvantages??

    pstmt = connection.prepareStatement("select * from TBL_NAME where username='"+Uname.getText()+"' and password = '"+new MD5().getHash(Passwd.getText())+"';");
    rset = pstmt.executeQuery();

    As of now everything works fine, but i'd like to know if its a good design.

    Thanks for your time

  2. #2
    Join Date
    Jan 2004
    you need a key to keep the entries unique. If the key is missing you can use one username and one password several times... - The German Perl-Community

  3. #3
    Join Date
    Nov 2003
    You should have a primary key defined so that (at the minimum)
    you have a means of quickly SELECTing from your records.
    A primary key automatically creates an index for you. This index
    will become very important when your database gets large.

    That said, there's no important reason why you need a separate
    ID field. Your username field would make a good primary key field if you
    want usernames to be unique. If usernames don't have to be unique,
    then you could make a compound primary
    key using both username and password.

  4. #4
    Join Date
    Jan 2004
    Thanks for your responses.

Posting Permissions

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