By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,372 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

Any information or suggested reading on...

P: n/a
How to use composite keys?
How do they migrate as FKs, how to input them from a form etc...

Cheers!

Konstantinos
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
A quick example that can be implemented in Access ( I used 2002 SP1).

Open a blank database and run(in order of appearance) the two following SQL
statements:

Statement 1:
CREATE TABLE Parents
(FathersName Text (10) NOT NULL,
MothersName Text (10) NOT NULL,
CONSTRAINT SetOfParents PRIMARY KEY (FathersName,MothersName));
End of statement 1

Statement 2:
CREATE TABLE Children
(FathersName Text (10) NOT NULL,
MothersName Text (10) NOT NULL,
ChildsName Text (10) NOT NULL,
CONSTRAINT PK PRIMARY KEY (FathersName,MothersName, ChildsName),
FOREIGN KEY (FathersName, MothersName )
REFERENCES Parents (FathersName, MothersName));
End of Statement 2

Then create a blank form in design view and name it Family, on the
properties page, data tab, set Parents as its record source. Make the
fields dialog visible
and drag the two fields to the form. Save the form.

Create a new blank form and name it Children, on the format tab of the
properties page set its default view to datasheet. On the data tab set
Children as the record source. Make the fields dialog visible drag
ChildsName to the details section of the form, and FathersName and
MothersName to the header section of the form. This keeps FathersName and
MothersName from being visible when you make a one to many form in the next
step. Save the form

Open the form Family in design view and drag the form Children in as a
sub-form. If you look at the properties page for the sub-form Access will
have set the LinkMaster, LinkChild properties with 'FathersName;MothersName'
nice the way it creates a delimited list with a semi-colon. Save the form
run it in form view, enter some families. Check out the tables, Access will
automatically enter the mothers and fathers name into the table children
from the form even though the fields are not visible.

Additionally, go to the Relationship view and add the two tables and look at
the properties of the relationship. This will illustrate how you could have
done the relationship other than in a ddl query.

I hope I typed these directions correctly and that the example helps. I
haven't seen a book that illustrates this, most just use a surrogate key or
simple key for a foreign key relationship.
--
Jeffrey R. Bailey
"Konstantinos" <no*****@noemail.net> wrote in message
news:10*************@corp.supernews.com...
How to use composite keys?
How do they migrate as FKs, how to input them from a form etc...

Cheers!

Konstantinos

Nov 13 '05 #2

P: n/a
> I hope I typed these directions correctly and that the example helps. I
haven't seen a book that illustrates this, most just use a surrogate key
or
simple key for a foreign key relationship.
--
Me neither...I havnt seen this in print before. Thanks for your suggestion.
I am trying it now.

Regards

Konstantinos
Jeffrey R. Bailey
"Konstantinos" <no*****@noemail.net> wrote in message
news:10*************@corp.supernews.com...
How to use composite keys?
How do they migrate as FKs, how to input them from a form etc...

Cheers!

Konstantinos


Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.