How to store old version of ID String in database design?

I am creating a small database for the laboratory. We have some rules for creating an identifier string for each item, so I do not want to store it in my database. The problem is that some changes in the data, for example, the personโ€™s reaction to this element have changed, causes the ID string to change. But I can not fix it for printed documents. How can I save the old version of this identifier string. I just can't change it, but that breaks the rules. Any suggestions?

+3
source share
3 answers

It is important to distinguish between a primary key that should uniquely identify a row in a table and some kind of smart key that products in catalogs usually have.

For the primary key, use auto-incrementing integer - there are very few exceptions to this.

Add columns for the things that you're trying to present in this intelligent key, eg Person, Project, Responseetc.

Add a separate column for this key and process it like any other field in the table - this should contain people who are used to this kind of thinking.

The smart key is wrong here, from the db development point, this key is pretty dumb.

+1
source

Expand at Damira Point

A smart key is what you say when

, ,

, Beakers,

-Beaker-SPAGE

"" " ", .

-. -, . , , . . - , , - .

, , ALTERNATE KEY CANDIDATE KEY... , , . , .

+2

for example, the personโ€™s response for this item has changed, causing the ID string to change

It looks like the workflow in your lab is broken. Identifiers should never change. Try to draw attention to your superiors.

0
source

Source: https://habr.com/ru/post/1765980/


All Articles