Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Nubie: primary key to span more than 1 field

Post Reply
Rolf
Posts: 28
Joined: Fri May 20, 2016 9:24 am

Nubie: primary key to span more than 1 field

Unread post by Rolf »

Database tables should have a primary key. nubuilderPro takes care of that behind the scenes, especially with the FastForms that I currently am using a lot as an entry point to my nuBuilder learning curve.

I've already been toying with the database fields that were created by FastForms and switched field types, etc., to be more in line with my plans. One thing I'd like to do is have a table where the primary key consists of more than one field (think about First Name, Family Name, Birthday and Birthplace fields in the Persons table, for example). I tried to put "first, family, birthday, birthplace" in the "Primary Key" field on the "Home - NuBuilder Form - Nubuilder Form - General" tab (separate fields by comma), but that didn't work.

Does nuBuilder support a primary key to span more than 1 field and if so, how to do it?
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Nubie: primary key to span more than 1 field

Unread post by admin »

Rolf,

Sorry, no it doesn't.

Steven
Rolf
Posts: 28
Joined: Fri May 20, 2016 9:24 am

Re: Nubie: primary key to span more than 1 field

Unread post by Rolf »

Thank you again for the quick response.

I tried another approach or workaround which was to CONCAT the fields in question into a new field in a MySQL view and use that for the form. But it seems that nuBuilder does not support forms to be based on views or does it? I always get "Form Wizard can't detect Primary Key on selected table." even when the concatination is left out and the view is simply a "SELECT * FROM table".

I guess I'll simply let nuBuilder have its PK as a separate field to keep it happy and then use an index in MySQL over the fields in question to make sure there are no duplicates.
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Nubie: primary key to span more than 1 field

Unread post by admin »

Rolf,

That's what I would do.

Steven
Rolf
Posts: 28
Joined: Fri May 20, 2016 9:24 am

Re: Nubie: primary key to span more than 1 field

Unread post by Rolf »

Thanks for confirming the approach.
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Nubie: primary key to span more than 1 field

Unread post by admin »

.
Post Reply