# How to setup two fields are primary key in same table

**URL:** <https://forum.bubble.io/t/how-to-setup-two-fields-are-primary-key-in-same-table/25630>\
**Category:** Database\
**Created:** [March 11, 2018, 3:24pm UTC](https://forum.bubble.io/t/how-to-setup-two-fields-are-primary-key-in-same-table/25630 "2018-03-11T15:24:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lhlong](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@lhlong](https://forum.bubble.io/u/lhlong)\
**Post date:** [March 11, 2018, 3:24pm UTC](https://forum.bubble.io/t/how-to-setup-two-fields-are-primary-key-in-same-table/25630/1 "2018-03-11T15:24:46Z")

</div>

Our database designs 2 fields of table is primary key as picture below (red lines is primary key), please tell me how to set it on Bubble database.  
 ![image](https://us1.discourse-cdn.com/bubble/original/3X/4/0/40bd8dce7455d510ffee3d2a4d4fbc428e94179b.jpg)

---

<div class="post-metadata">

**Author:** ![NigelG](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@NigelG](https://forum.bubble.io/u/NigelG)\
**Post date:** [March 11, 2018, 5:16pm UTC](https://forum.bubble.io/t/how-to-setup-two-fields-are-primary-key-in-same-table/25630/2 "2018-03-11T17:16:14Z")

</div>

As my previous answer, bubble is not mysql.

Implement your own integrity and keys.

---

<div class="post-metadata">

**Author:** ![mguerrasio](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@mguerrasio](https://forum.bubble.io/u/mguerrasio)\
**Post date:** [March 11, 2018, 9:09pm UTC](https://forum.bubble.io/t/how-to-setup-two-fields-are-primary-key-in-same-table/25630/3 "2018-03-11T21:09:12Z")

</div>

Actually, you can do a form of referential integrity. You could make a Contract\_Number table and a Device\_Model table and then in your Contract-Device table you can make a field that IS a Contract\_Number and a field that IS a Device\_Model. This will make it impossible for Contract\_device to have a Contract\_Model or Device\_Model that does not exist.

---

<div class="post-metadata">

**Author:** ![lhlong](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@lhlong](https://forum.bubble.io/u/lhlong)\
**Post date:** [March 13, 2018, 4:01pm UTC](https://forum.bubble.io/t/how-to-setup-two-fields-are-primary-key-in-same-table/25630/4 "2018-03-13T16:01:40Z")

</div>

Yes, please tell me how to implement own integrity and keys in bubble?

Regards,  
Long

---

<div class="post-metadata">

**Author:** ![lhlong](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@lhlong](https://forum.bubble.io/u/lhlong)\
**Post date:** [March 13, 2018, 4:21pm UTC](https://forum.bubble.io/t/how-to-setup-two-fields-are-primary-key-in-same-table/25630/5 "2018-03-13T16:21:35Z")

</div>

Hi Mguerrasio,

Thanks for your feedback!  
I did as you mention for Device\_Model and Contract\_Number tables then in Contract\_Device I want to set Contract\_Number and Device\_Model is primary key of Contract\_Device table, please tell me if possible to set Contract\_Number and Device\_Model is foreign key in table Device\_Assign as picture below, please tell me detail if it possible.

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/9/b/9bbbfea88c513c53291a6f447028c0f3a04922da.png)

Regards,  
Long

---

<div class="post-metadata">

**Author:** ![ankush.sharma](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@ankush.sharma](https://forum.bubble.io/u/ankush.sharma)\
**Post date:** [June 30, 2022, 12:44pm UTC](https://forum.bubble.io/t/how-to-setup-two-fields-are-primary-key-in-same-table/25630/6 "2022-06-30T12:44:29Z")

</div>

![9bbbfea88c513c53291a6f447028c0f3a04922da_2_690x481](https://us1.discourse-cdn.com/bubble/original/3X/6/c/6cec569ce78fd0b8459a795b20cb3847914018c3.png)  
Hi  
i mention for Device\_Model  
is this possible in [bubble.io](http://bubble.io).

Is this right choice to create application that contain multiple table more then 20,30 or 50 & more table with huge data in it. like we done in MySQL relational database.

is bubble is right choice for this.

---

<div class="post-metadata">

**Author:** ![herdycenn](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/herdycenn/32/148380_2.png) [@herdycenn](https://forum.bubble.io/u/herdycenn)\
**Post date:** [October 25, 2022, 9:02am UTC](https://forum.bubble.io/t/how-to-setup-two-fields-are-primary-key-in-same-table/25630/7 "2022-10-25T09:02:16Z")

</div>

Up. I am also looking into this. As of what is shown in the Bubble’s interface, I don’t think there is any possibility of having more than one Primary Key Fields
