--- url: "https://martinfowler.com/eaaCatalog/identityField.html" titulek: "Identity Field" h1: "Identity Field" popis: "Saves a database ID field in an object to maintain identity between an in-memory object and a database row." jazyk: "" kanonicka: "" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 21:08:45" znaku: 944 slov: 149 kodovani: "utf-8" sha256: "3d8350e41474b2035d588911bdc6a00c92deabfa5d7fe0db32fdfeb0b25e90ea" --- # Identity Field Saves a database ID field in an object to maintain identity between an in-memory object and a database row. Relational databases tell one row from another by using key - in particular, the primary key. However, in-memory objects don't need such a key, as the object system ensures the correct identity under the covers (or in C++'s case with raw memory locations). Reading data from a database is all very well, but in order to write data back you need to tie the database to the in-memory object system. In essence, Identity Field is mind-numbingly simple. All you do is store the primary key of the relational database table in the object's fields. for more details go to [Chapter 12](https://learning.oreilly.com/library/view/patterns-of-enterprise/0321127420/ch12.html#ch12lev1sec1) of the online ebook at oreilly.com This pattern is part of [Patterns of Enterprise Application Architecture](.) [Martin Fowler](/) 05 March 2003