Quantcast
Channel: Active questions tagged surrogate-key - Database Administrators Stack Exchange
Browsing latest articles
Browse All 31 View Live
↧

Problem with a surrogate key?

I am working with an application for students management. For the student's table I used a surrogate key (auto increment id). The problem I face with the surrogate key is when the user wants to show...

View Article


Can a surrogate key and a primary key be in the same table?

For example we have:Surrogate key: ABC123Primary key: 1Name: JamesIs this legit in a Data Warehouse table?

View Article


A question regarding the performance of normalization

I am sorry this is such a newb question, but it is one thing I am having a difficult time wrapping my mind around, and after an evening spent reading I finally just decided to ask for some...

View Article

Image may be NSFW.
Clik here to view.

Should I set document version field to be part of a primary key

Should I set document version as a primary key I am working on a document management system, and I have these two tables representing part of the whole tables.On the DocumentVersion table I have set...

View Article

How to get a surrogate key value in order to put a foreign key in and create...

I am trying to create two relationships between three tables, using foreign keys with values of primary keys, which are surrogate keys. But I don't understand how to enter the right value in the...

View Article


Image may be NSFW.
Clik here to view.

Why should I create an ID column when I can use others as key fields?...

Possible Duplicate:Why use an int as a lookup table's primary key?So far, I'm accustomed to creating an ID column for every table and it is practical in a way that it makes me not think about decision...

View Article

Reassigning surrogate keys?

I have a few tables with surrogate keys (SERIAL PRIMARY KEYs unique to each tables). These tables are used by other tables, with references to these keys. My usage of these is quite simple :select *...

View Article

Surrogate key resolution, or what am I missing in the Surrogate v Natural...

I've read a lot from both camps in the surrogate vs. natural key debate. What I am struggling to understand, and what seems to be glossed over, especially in explaining how surrogate keys are more...

View Article


Surrogate vs composite key in hierarchical data structure

I'm currently evaluating a schema for a hierarchical data structure. My main problem is how I should design the schema to prevent inconsistent data (reference of foreign key in another hierarchy). The...

View Article


PostgreSQL surrogate keys: use sequence/bigint or OID?

I'm looking at a need for surrogate keys in tables I'm designing on a PostgreSQL-derived DBMS (Citus). Would OIDs suffice? Is there a downside to using them instead of creating a bigint field and a...

View Article

Surrogate keys as Foreign Keys

I have a question about Surrogate keys, say i have two tables(in sql server): Table A: Student_ID, Name, School, SectionTable B: Book_ID,Student_ID, IssueDate, BookName If Student_ID is a clustered...

View Article

What are the consequences, positive or negative, to having a surrogate...

I recently made a table that looks like the one belowCREATE TABLE example( id SERIAL PRIMARY KEY, subindusty_id INT UNIQUE NOT NULL, name TEXT NOT NULL -- other fields...)I realized that in this table...

View Article

Common term for tenant-based keys [closed]

Assume the following schema:ID  | TENANT | TENANT_CUSTOM_ID346 | 101    | 1 347 | 102    | 1 348 | 101    | 2 349 | 101    | 3 350 | 101    | 4 351 | 102    | 2 352 | 103    | 1What is another name (or...

View Article


Image may be NSFW.
Clik here to view.

Identity versus Composite values for Primary Keys in Many-To-Many Tables...

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 tables - be...

View Article

Surrogate key vs Natural key

I have a table called devices. Most of the devices that will get stored in this table can be uniquely identified by their serial number and part number. But there are some device types that do not have...

View Article


What normal form does a surrogate key violate?

I have following question:"What normal form does a surrogate key violate?"My thought was the 3rd normal form, but I'm not quite sure it's just an assumption i am making. Could someone explain that to me?

View Article

Should every table have a single-field surrogate/artificial primary key?

I understand one benefit of surrogate/artificial keys in general - they do not change and that can be very convenient. This is true whether they are single or multiple field - as long as they are...

View Article


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...

View Article

Image may be NSFW.
Clik here to view.

Do natural keys provide higher or lower performance in SQL Server than...

I'm a fan of surrogate keys. There is a risk my findings are confirmation biased. Many questions I've seen both here and at http://stackoverflow.com use natural keys instead of surrogate keys based on...

View Article

M:M Table Design - Use of PK

I have a many-to-many table that contains id's from 2 related tables.For creating a primary key on this table, is it better to create another integer column and have that as a surrogate PK?Or should I...

View Article

Does adding a surrogate key get rid of an identifying relationship between...

In the following example, we have a Comments table with a composite primary key (PK)CREATE TABLE Comments ( video_id INT NOT NULL, user_id INT NOT NULL, comment_dt DATETIME NOT NULL, PRIMARY KEY...

View Article


Image may be NSFW.
Clik here to view.

Composite primary key plus a separate (surrogate) id column for foreign key...

I am trying to build a database about locations like so:Country → Region → TownCountries will be populated with a list of pre-defined worldwide countries, regions & towns are input by users.Region...

View Article


What problems are there in not using a primary key column at all?

What purpose would a primary key column serve on a table such as post_versions here? Nothing refers to it, and there are no queries where I will ever want to select a row by post_versions.id. It'll be...

View Article

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...

View Article

Image may be NSFW.
Clik here to view.

Natural Keys vs Surrogate Keys part 2

A while back, I asked if surrogate keys provide better performance than natural keys in SQL Server. @sqlvogel provided an answer to that question yesterday that caused me to revisit it. This question...

View Article


Should a inherited table have a new surrogate key, or just use parent table's...

I am modeling some things with an "is a" relationship (aka inheritance), and there were two ways to go about it in regards to the inherited table's primary key and foreign key pointing back to the...

View Article

If all associated attributes of an intended primary key are identical, is it...

I'll start with an example. If I have a person table with intended surrogate primary key Id:+----+------+------------+-------------+| Id | name | DoB | SSN |+----+------+------------+-------------+| 1...

View Article

Insert results from query, update old existing row if query doesn't still...

I am trying to refactor a table which contains historical data and therefore isn't ever deleted, but has an 'active' field.Each day we run a query (a few joins, but quite slow) to get some data to...

View Article

How not to "naturalize" surrogate keys?

Don't naturalize surrogate keys. As soon as you display the value of a surrogate key to your end users, or worse yet allow them to work with the value (perhaps to search), you have effectively given...

View Article



How to get the "best of both worlds" with natural and surrogate keys? And...

I am designing my first database, and I find myself frustrated by the choice between storing an integer or a string for each instance of a categorical variable.My understanding is that if I have a...

View Article
Browsing latest articles
Browse All 31 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>