Linked Questions

5
votes
8answers
5k 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. ...
3
votes
0answers
27 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? ...
19
votes
4answers
849 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 ...
8
votes
2answers
18k 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, ...
13
votes
3answers
4k 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
4answers
782 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 ...
7
votes
2answers
6k 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
2answers
2k 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-...
4
votes
2answers
534 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 ...
0
votes
2answers
216 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 ...
1
vote
1answer
124 views

Multiple one to many relationships in series

I am making a DB for storing reports that have following fields: Ad_system, Ad_Campaing, Ad_Group, Keyword, Date, Impressions, Clicks, Conversions Logic is that, Ad_system can have multiple ...
-2
votes
2answers
84 views

How to identify foreign id value [closed]

People say that the primary key for a table should ideally be an integer "Id" which has no meaning in the outside world. Under these circumstances how does one handle the following situation in a ...
0
votes
1answer
45 views

Should I record ID numbers in a table where I record who look whom profile page

This is how I have designed: visitorID visitedprofileID datetime Is it a good idea to add an ID (primary key) to the table, I mean recordID (primary key). (MySQL with PHP)