filemakerjim Posted May 20, 2005 Posted May 20, 2005 I am sure there is a simple way to do this but I am brand new (1.5 days) to filemaker. I have some experience with SQL Server and Access but no Filemaker. I am having a problem creating a composite key. What I want to do is have a table that does not allow data to be entered when the information in two seperate fields are the same. An example would be 3 tables-Class, Student, ClassMember. ClassMember would be the entity that matched up a student with a class but I want to prevent having records in ClassMember that have identical Student and Class information in it. I don't want to have multiple records with the same info in them. A student can be in many classes and a class can have many students but I don't want to be able to enter the student in the same class twice. Thanks in advance for all your help.
RalphL Posted May 20, 2005 Posted May 20, 2005 I have a sample file that shows the way I do this. I use a one to many relationship from Class to ClassMember and a one to many from Student to ClassMember. I use a one to one relationship to create new records in ClassMember. This is an AND relationship. I use a value list which shows only Class Student pairs that have not been used.
Ender Posted May 20, 2005 Posted May 20, 2005 Try a self-join on the ClassMember table using both StudentID AND Class ID. If when you go to add a new ClassMember, there is already a related record, then you can show an error. The specifics about how to go about this validation depends on how you're adding records. If you use a global for adding a Student to a Class (or a Class to a Student,) then the relationship would use this global for one of the fields on the parent side, and the validation would be a script that just checks if the related key is empty before adding the actual record in the ClassMember table. In this case a global representing the new ClassID would reside in Student or a global representing the new StudentID would reside in Class, and the relationship would be from that table to the ClassMember table. If you add the records by filling in a row of a portal, then this can be more tricky.
Recommended Posts
This topic is 7184 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 accountSign in
Already have an account? Sign in here.
Sign In Now