I'd like some advice designing my database tables for a small project I'm working on. Assuming in this systems I have articles
, subarticles
, and comments
.
Each article can have subarticles. Both articles and subarticles can have comments. I considered having an autoincrementing int primary key for each table (i.e. articleId, subarticleId, and commentId). Subarticles would have an articleId as a foreign key into the Article
table etc.
But I'd like to have a notion of a globally unique Id for certain reasons. What would be the best way to implement this? Should I have a uuid
primary key in each table and use the previously mentioned Id column as just a regular column (since I still would like a logical number associated with each object)? Or should I make some sort of main object
mapping table containing the uuid
?
Any suggestions on good ways to implement this would be appreciated!