Jump to content

Newbie Basic Relation Table help


flybriguy

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

Recommended Posts

I can't even figure this one out through filemaker's own tutorial help function . . . . How do I create a relation? (and through which table to I make it/have it show through?

Let's say I am creating a database with two tables: Company, and People. In the Company table I have a "name of company" field as well as a "ID" field with an auto-entry serial number, and an "address" field. In the People table I have the same "name" field and also with "ID" field. If say I want to have the name of the company each person is associated with and it's address to show what other fields do I add? and to which table?

**I noticed that in creating a new table that a new separate layout will automatically be made once I specify a field for the new table (with the Define Database Box) . . . . . however if I start by creating a whole new Layout I notice that a new table won't necessarily be created for me. If I start by creating a new layout/report then I am prompted to "show records" from the other layouts and and "move" over pre-existing fields already created. How should I consider this when creating a relational database?

-brian

Link to comment
Share on other sites

In the People table you would typically have 2 ID fields. The "primary" id field is the PeopleID, which is auto-enter (like the CompanyID field in the Company table). But the People file also has a CompanyID field. It is NOT auto-enter. It is a "foreign key," entered either manually (clunky) or via a relationship, ie., through a portal in Company.

On the relationship graph you would drag a line between the Company table occurrence and the People table occurrence, from the CompanyID to CompanyID. In the relationship dialog turn on "Allow creation of related records" on the PEOPLE side of the relationship.

As far as tables and layouts, the table (and at least one of its table occurrence(s) on the graph) comes first, then the layout. A table occurrence can have many layouts, but a layout belongs to only 1 table occurrence.

*The field types should be the same, either text or number, but the same.

Link to comment
Share on other sites

It is a "foreign key," entered either manually (clunky) or via a relationship, ie., through a portal in Company.

. . . . . could you expand on this just a little? I'm successful in creating the relationships now by tagging the primary key ID into the foreign key entered manually. But on one on of the examples you provided me with earlier (attached) I can't locate or see where the "company id" is located on the people layout. I can only spot "company name," but no id number or field to connect the direct relationship.

-brian

CompPeople.zip

Link to comment
Share on other sites

The CompanyID is automatically created by entering any other data into the portal, because of the "Allow creation of related records" (as Genx said somewhere, I think; dual posting causes these problems, flybriguy).

One doesn't normally show this to the user on a layout, because it's somewhat dangerous. But it's there, and I added it to the layout so you could see.

CompPeople2.zip

Link to comment
Share on other sites

This topic is 6575 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.