Jump to content

how do relationships work?


LoneReaper
 Share

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

Recommended Posts

I want to link these 2 db.

They both have title fields, they both have author fields, ect... There are a couple fields that one db has that the other doesnt of course.

i want the "HBtemplate" db to be the primary db and when i add new records or import new records the "RWtemplate" db adds those same records to it and puts the field values in the corresponding fields. How would i do that?

Database.zip

Link to comment
Share on other sites

In general, relationships are used to AVOID duplication of data across multiple files or "tables." In database-speak this is called "normalization" of data. The idea is, if I change for example a person's title, I would only need to change it in one place -- I wouldn't have to worry that the title field was different in other files, because it wouldn't exist in other files. It would only appear in other files via a relationship to that person's contact record.

What you have described doesn't sound like it necessarily even requires a relationship. You would just create a script in each file that copies the information.

But think about how I just described relationships -- maybe you don't need to duplicate the information, but rather can display it in the primary or related file via a relationship.

A final point: it is usually not a good idea to use an actual data field (e.g. author or title) as a basis for the relationship. Instead, create an auto-entered serial number in each file that will serve as that file's "primary key." In the related file, create a field of the same type (text or number) that will store the key of the primary file when that record is related to the primary file. This field is the "foreign key."

Link to comment
Share on other sites

okay. So i put a field in both dbs that is called "PrimaryKey" and i defined a relationship, i check both allow creation and deleted related records. what would be the next step. i want to add a record to the HBtemplate db and have it appear in the RWtemplate db?

Link to comment
Share on other sites

i got it, i needed to define the look up value based on the relationship and put in the field that i want looked up. then here is the question.

how can i make it so when i create a record in the HBtemplate db it duplictes that record in the RWtemplate file? I check the box in the relationship to allow creation...

Link to comment
Share on other sites

One way to do this would be to create a layout of global fields where the user enters the data. Make a button on the layout that says "Save" or something. Attach a script to this button. The script would look something like this:

Enter Browse Mode

New Record

Set Field [author, gAuthor]

Set Field [title, gTitle]

Go to layout [data view]

Perform Script [external, "create my record"]

The "create my record" script is a script in the related file that would be essentially the same, except it would look like this:

Enter Browse Mode

New Record

Set Field [author, primary::gAuthor]

Set Field [title, primary:: gTitle]

Link to comment
Share on other sites

This topic is 6523 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
 Share

×
×
  • Create New...

Important Information

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