# Model for MS SQL table which does not have primary key?

**URL:** <https://discourse.cakephp.org/t/model-for-ms-sql-table-which-does-not-have-primary-key/10258>\
**Category:** Need Help\
**Created:** [March 29, 2022, 10:04pm UTC](https://discourse.cakephp.org/t/model-for-ms-sql-table-which-does-not-have-primary-key/10258 "2022-03-29T22:04:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![general2000vn](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@general2000vn](https://discourse.cakephp.org/u/general2000vn)\
**Post date:** [March 29, 2022, 10:04pm UTC](https://discourse.cakephp.org/t/model-for-ms-sql-table-which-does-not-have-primary-key/10258/1 "2022-03-29T22:04:11Z")

</div>

I have existing database in MS SQL, and it’s table does not have primary key.  
How can I build model for that kind of tables?  
Thank you.

---

<div class="post-metadata">

**Author:** ![jimgwhit](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/jimgwhit/32/378_2.png) [@jimgwhit](https://discourse.cakephp.org/u/jimgwhit)\
**Post date:** [March 30, 2022, 4:03am UTC](https://discourse.cakephp.org/t/model-for-ms-sql-table-which-does-not-have-primary-key/10258/2 "2022-03-30T04:03:07Z")

</div>

I suggest adding a pk. Otherwise how are you relating any data? Or just use query builder.
