Linked Questions

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. ...
sooprise's user avatar
  • 249
0 votes
1 answer
69 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 ...
beginsql's user avatar
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? ...
NingLee's user avatar
  • 131
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. ...
Ruslan's user avatar
  • 111
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 ...
Luciano Andress Martini's user avatar
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 ...
Callie J's user avatar
  • 492
10 votes
2 answers
19k 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, ...
Jake Wilson's user avatar
  • 2,427
10 votes
4 answers
897 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 ...
Jon of All Trades's user avatar
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 ...
Joril's user avatar
  • 441
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-...
Ingó Vals's user avatar
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 ...
igelr's user avatar
  • 2,132
3 votes
2 answers
320 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 ...
Timbalero's user avatar
  • 101
3 votes
1 answer
651 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 ...
Bhrugesh Patel's user avatar
2 votes
1 answer
2k 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 ...
Prisoner ZERO's user avatar
4 votes
2 answers
831 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 ...
dawydiuk's user avatar

15 30 50 per page