sql - table primary key for concurrent users -


i making first website database. lets have table called "items". users may send items stored in database. however, don't know type of primary key items table should use.

i thought using integer primary key. every time user enters item, find current maximum value in table, , increment 1 new value. method happens if 2 users enter items @ same time table? items possibly end using same maximum value , end having same primary key resulting in error?

another way thought using character primary key based on userid , date entered in users table. create primary key out of "userid - entrydate". way seemed "unclean" me.

i wondering there standard way of handling primary keys in databases of web applications may have multiple users entering information @ same time?

sorry new web dev , databases. information, using node.js server, , postgresql databse.

there's data type serial auto increment , used primary keys.

serial data type documentation

the data types serial , bigserial not true types, merely notational convenience setting unique identifier columns (similar auto_increment property supported other databases). in current implementation, specifying


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -