Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Uniqness on two fields??

Featured Replies

I have a many to many rellationship and I have devided it so I have a rellationship table it looks like this:

Image (with id)

Image_Searchword(ImageID and SearchwordID)

Searchword (with id)

Now I can add the same searchword on an Image more than once, and I dont want that to happen, how do I make it unique on the combination of ImageID and SearchwordID in the table Image_Searchword

Thanx for the help!

// Jocke

One way to handle this is to make your searchword value list appear in a checkbox field that displays in a new, small window whenever the user wants to edit the searchwords associated with the image(script triggered by button). This, with a "Close Window" button on the layout, and a calc field on your original layout the contatenates the keywords, is very much "a la MS Outlook", making it a familiar interface to many...always a plus!

FYI The formula to concatenate the keywords is as follows:

[color:blue]Case ( ValueCount ( keywords_cb ) = 1 ;

/*If only 1 checkbox is checked*/

Substitute ( LeftValues ( keywords_cb ; ValueCount ( keywords_cb ) ) ; "¶" ; "" );

/*If any number other than 1 checkbox is checked, put commas in between keywords, but omit trailing comma*/

Substitute ( LeftValues ( keywords_cb ; ValueCount ( keywords_cb )-1 ) ; "¶" ; ", " ) & Substitute ( RightValues ( keywords_cb; 1 ) ; "¶" ; "" ))

Hi comment,

As it turns out, I'm currently developing a digital asset (mostly photos) database and I started off by using the same approach as Jokez, i.e. separate table for keywords (searchwords) with many-to-many relationship to assets. After pondering for a while I decided to omit that relationship to the keywords table, and just use that table's records for a value list of keywords, which in turn are selected in a checkbox field in the Assets table. This seems to work very well and solves the problem of having the same keyword assigned multiple times to an asset record. Do you foresee any issues that might arise later that would cause problems with keyword searches, etc.?

I can't think of any specific issue at the moment, but then I don't know how far you intend to take your solution. For those uses that I can imagine I think it should be fine. Probably even preferable - keywords are not really an entity in this situation.

keywords are not really an entity in this situation.

Thanks, comment, that was my logic too. Unfortunately, my logic has painted me into corners before, so it's nice to get an opinion from someone with more FMP knowledge than me. :)

  • Author

I used a field that took the two other fields and put them togheter ImageID and SearchwordID in a ImageSearchwordID field. Then I checked that field for uniqness... that worked like a charm :)

// Jocke

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.