Should primary key be exposed?

Should primary key be exposed?

It’s entirely fine to expose keys for technical uses. Also, if you do use some surrogate value instead, that’s not necessarily more secure. Yes, exposing keys is information that can be used as an attack. Especially if they are predictable.

Should I use UUIDs?

The point of a UUID is to have a universally unique identifier. There’s generally two reason to use UUIDs: You do not want a database (or some other authority) to centrally control the identity of records. There’s a chance that multiple components may independently generate a non-unique identifier.

Is primary key necessary for every table?

Every table can have (but does not have to have) a primary key. The column or columns defined as the primary key ensure uniqueness in the table; no two rows can have the same key. (The data foreign key column must exist in the primary key column in the first table.)

Is it safe to use UUID?

UUIDs are safe enough for nearly all practical purposes1, and certainly for yours.

Why do you need to expose a primary key?

Activity is very fine granular so it is together in some container object, lets call it “Task”. User A wants to send User B to some Task so he sends him a link (HTTP) to get some Activity done there. User B has to go outside the building so he opens the Task on his mobile device.

Is there a problem with the term primary key?

The problem / misunderstanding implicit in your question is due to inappropriate use of the term primary key. A primary key is just one among several “candidate” keys (several possible identifiers in a database table).

How are primary keys different from other keys?

A primary key is just one among several “candidate” keys (several possible identifiers in a database table). The primary key doesn’t necessarily require any fundamentally different property to any other key so assertions and design principles that apply specifically to primary keys and not to other keys are always suspect and often wrong.

Why do I need to change my primary key?

Because Primary Keys are an implementation detail. If you migrate databases, your primary keys might change due to order of insertion, removal of old records… a few different reasons.