database - SQL Server referencing a foreign key to a non-primary key column -


recently ran situation following:

we designing database , predicting data grow millions records within 6 months. , want each row should have guid unique id allows move data olap/archive databases later, after many arguments on identity , guid key, came guid unique id. however, guid primary key bad idea, therefore have primary key of table identity column. design looks below

users:

| id (pk, identity)                                                 | | userid (guid, unique-constraint, non-clustered index)             |   | name                                                              | | email                                                             | | ...                                                               | 

notes:

| id (pk, identity)                                                 | | noteid (guid, unique-constraint, non-clustered index)             | | userid (guid, foreign key users(userid)                        | | title                                                             | | text                                                              | | ...                                                               | 

when moving data archive don't need care identity key anymore.

is there problem design ? how performance ? please give me advice, thanks.

even though don't have guid primary key, you'll still using joins, making more work server.

is there reason you're not using users.id fk target?

userid (int, foreign key users(id) 

bear in mind you'd wanting index above column, way still end 2 guid indexes on table, fragmented bet programmers making random guids in app tier, not making newsequentialid() in db?


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -