Hi,

I had a discussion with two of my profesors during my bachelor colloquium that PKs could change after Export / Import

I said: no, why should they? They said: How do you know?

So, this is the scenario:

  • 2 Tables (customer: customer_id (PK) and users: user_id (PK), customer_id (FK))
  • I implemented a pretty simple authentication system: a customer with the ID 1 is the owner of the application, so all users with the customer_id 1 are 'admin'-like users

One of them said: It's a bad design to assign access rights to a certain ID, which is correct but does it make it a bad design if it's always the first customer? Anyway, the main question is:

Is a PK really able to change after export / import? This just doens't make sense to me because it would completely destroy the integrity of a database

asked Oct 29 '14 at 09:01

KaiR's gravatar image

KaiR
6112


2 Answers:

Everything that is intended for backup will not change any data.

Nevertheless, someone could write an export/import program that does change data. Sometimes, it's even a requirement: e.g. when sensitive data is to be imported into a test system—data has to be anonymized first. The data protection guidelines may or may not require the surrogate keys to be changed as well (keeping all the constraints valid, of course).

It really depends on what kind of system you are thinking: more a blogging software, or more something like banking or healthcare?

answered Oct 29 '14 at 09:08

Markus%20Winand's gravatar image

Markus Winand ♦♦
93651120

It was a bugtracking system and a 'moving the whole application from one server to another' scenario I also told them if you just simply export and import the data, nothing should happen.

My bad was that I had no answer to "How do you know?" I guess

answered Oct 29 '14 at 09:21

KaiR's gravatar image

KaiR
6112