Linked Questions
19 questions linked to/from Should every table have a single-field surrogate/artificial primary key?
6
votes
8
answers
7k
views
Should you ever not assign an unique ID to each row in a table? [duplicate]
Possible Duplicate:
Should every table have a single-field surrogate/artificial primary key?
I can't imagine ever not using a unique ID with every table, which is why I'm asking this question. ...
0
votes
1
answer
95
views
Do I need to implement id column to table if i know that every added row will be unique? [duplicate]
I want to create database which allow me to store IT job offers from various websites. While creating ER diagram I started wondering if I really need an id column in one particular table. Look at this ...
3
votes
0
answers
28
views
Is it a good way to use an auto increment integer field as the primary key? [duplicate]
In database design, is it a good way to use an auto-increment integer field as the primary key?
For Example, I have a tenant table, tenant_id is unique. In this case, do I need a auto_increment key?
...
1
vote
0
answers
13
views
Primary key design - autoincrement vs composite vs artificial key for time-series data [duplicate]
I have a non-relational table that records visits per area across time (months):
area_id
period
visitors
visits
91387821
2022-04
452
664
91387821
2022-05
516
704
105252924
2022-04
8834
20445
etc.
...
18
votes
4
answers
1k
views
Entity relationship problem
I have 4 tables related like this (it's an example):
Company:
ID
Name
CNPJ
Department:
ID
Name
Code
ID_Company
Classification:
ID
Name
Code
ID_Company
Workers:
Id
Name
Code
ID_Classification
...
15
votes
4
answers
6k
views
Foreign keys - link using surrogate or natural key?
Is there a best practice for whether a foreign key between tables should link to a natural key or a surrogate key? The only discussion I've really found (unless my google-fu is lacking) is Jack ...
10
votes
2
answers
20k
views
How to use Unique key via combinations of table fields?
Take a look at the following sqlfiddle: http://sqlfiddle.com/#!2/dacb5/1
CREATE TABLE contacts
(
id int auto_increment primary key,
name varchar(20),
network_id int,
...
10
votes
4
answers
930
views
What are the performance considerations between using a broad PK vs a separate synthetic key and UQ?
I have several tables where records can be uniquely identified with several broad business fields. In the past, I've used these fields as a PK, with these benefits in mind:
Simplicity; there are no ...
9
votes
2
answers
12k
views
Non-unique multicolumn foreign key
I have a "comments" table that models a conversation on a topic, like this:
id serial
topic_id integer
parent_comment_id integer
body text
So, every comment has a reference to its topic AND ...
5
votes
2
answers
4k
views
Constraint many to many table between two child tables
New to this exchange site so I hope my question isn't inappropriate.
Creating a somewhat normalized database I had one design problem I'm not sure how to handle efficiently.
One table has a One-To-...
1
vote
2
answers
3k
views
What are the disadvantages of using surrogate keys? [closed]
I am using MS SQL Server but in general database design I want to know what problems can arise when every row in a database has its auto generated surrogate key value.
I know some advantages, for ...
3
votes
2
answers
390
views
SQL Server - creating a clustered index in a large heap - should I add a column?
I'm going to add a clustered index to a fairly large table:
over 7 million records
106 columns
no PK
no other indexes.
There is an Id column which could potentially be used for the index ...
3
votes
1
answer
666
views
Surrogate key / Primary key: Better to use an existing unique data field or create a key field?
I am not sure if this question has been asked or not. At least I couldn't find it.
I am curious about a primary key in terms of efficiency with data searching and retrieval.
This is a hypothetical ...
2
votes
1
answer
3k
views
Identity versus Composite values for Primary Keys in Many-To-Many Tables [closed]
I am in the middle of an interesting "Data Architecture" discussion at a place I am contracting & need some input.
As a habit, I always create a Surrogate Key as the Primary Key in my ...
4
votes
2
answers
877
views
Potential schema for product failures and repairs
I'm creating a schema for product failures and repairs and would appreciate feedback on the schema.
The database is intended to capture all product failures and corresponding repairs. A product can ...