5 Replies Latest reply on May 4, 2011 11:10 AM by philmodjunk

    composed primary key

    RossanoIennarelli

      Title

      composed primary key

      Post

      Hi all,

      I'm making a db that contains an article registry, each article is made by 2 or more articles (sub-articles). The situation is managed with two tables. In the sub-articles table i want make a primary key composed by 2 field, how I can do this?

        • 1. Re: composed primary key
          philmodjunk

          Please explain in more detail. Chances are that you should not use the fields/values you have in mind as primary keys, but rather as "label data" while a serial number field is used as the primary key. Describe what you want in more detail and I can then explain how/why to use the serial number field in its place while not losing any of the features you want for your database.

          • 2. Re: composed primary key
            RossanoIennarelli

            I've an article A12.

            A12 is made by B1 and C1. The rows in the db are :

            A12 B1

            A12 C2.

            I must insert x times A12 with all of his parts in a production order.

            I want avoid the repetition of the combination : A12 B1 and A12 C1

            • 3. Re: composed primary key
              philmodjunk

              A12 is made by B1 and C1. The rows in the db are :

              A12 B1

              A12 C2.

              Don't you mean that the rows are:

              A12 B1
              A12 C1

              ?

              What do you mean by "rows" here? Do you have a table of related records with one record for each row or?

              I think that this is a bill of materials

              Use a serial number field to uniquely identify the item being produced. Put the list of materials in a related table using this relationship:

              Products::ProductID = BOM::ProductID

              That may be what you have in mind, the abstract use of A and B leaves me unsure, however.

              To insure unique entries in the bill of materials, you can use an additional text field in the BOM table with this auto-entered calculation:

              ProductID & " " & MaterialID

              Then use the Validation tab put a unique values validation rule on this field.

              • 4. Re: composed primary key
                RossanoIennarelli

                I was just thinking to that solution, the union of the two fields, you were right that is a kind of bill, thanks a lot Phil!!

                However I'm perplexed about the fact that filemaker doesn't manage a composed primary key, if not mistaken access can do taht

                • 5. Re: composed primary key
                  philmodjunk

                  Compared to Access. FileMaker doesn't manage any primary keys at all. Wink

                  Each system has its strengths and weaknesses.