Jump to content

Composite Primary Keys in Filemaker


mlenny

This topic is 8481 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

I'm new to FM and coming from 9 months reading general DB theory - now hitting problems transferring theory into FM.

How can I implement a composite primary key in FM? In other words, several fields whose values singularly are not unique, but whose combined value must be unique, to be used as a match field in a related file.

An example is my current problem: a software database with developer, title and version fields, e.g. 'Microsoft' 'Word' and '5.1'. None of these values are necessarily unique. However, I want the three combined ('Microsoft Word 5.1') to be unique, so the same package does not get entered more than once.

I can make a calculation field using concatenation to combine them, but how can I then validate that result as being unique?

This might not even be the right approach, so all suggestions welcome.

[This message has been edited by mlenny (edited February 08, 2001).]

[This message has been edited by mlenny (edited February 08, 2001).]

Link to comment
Share on other sites

One option, assuming FMP interface and not a CDML solution, is to concat the field as you described and create a self relationship (to the same database) based on the calculated field, call it 'unique'.

Create a field called 'alert_check' based on the relationship (doesn't have to be on the layout).

Create a calculated field called 'alert' as follows:

If( Count(unique::alert_check) > 1, "Your alert message goes here!!!", "")

Place this field on the layout with whatever notification message you want.

HTH

Link to comment
Share on other sites

  • 2 weeks later...

Have you tried something as simple as making a new field (call it unique) which is a text calculation and must be unique as follows:

unique=fieldA&fieldB&fieldC&fieldD&fieldE

This field would not have to appear on the layout but would alert you if the 5 fields when combined duplicated another record in the file.

------------------

Kathy Eldredge

the Wild Sicilian

Link to comment
Share on other sites

This topic is 8481 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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