469,286 Members | 2,521 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

Creating a one to one relationship

43
Hi,
I have a 'Client table' and a 'Credit Card table' that need to be seperated for security reasons but I am not sure how you set up the one to one relationship. I currently have the two Primary Key fields ('Client ID' and 'Cardnumber') linked together and this appears as a one-to-one relationship in the relationships table. However, I am not sure if this is correct as the cardnumber field will not let me change the properties e.g. input mask and data type for a credit card number and defaults to those of the clientID.

Am I doing something wrong? More details including field names can be included in necessary.

Many thanks in advance for any help

Edd
Mar 8 '07 #1
5 15133
NeoPa
32,173 Expert Mod 16PB
You would need a ClientID field (or equivalent) in both tables.
It would be PK in the 'Client Table' and FK in the 'Credit Card Table'.
Mar 9 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
Edd

As NeoPa says the tables should be as follows:

tblClients
ClientID (Primary Key)
ClientName

tblCreditCards
CardNumber (Primary Key)
ClientID (Foreign key referencing the primary key of tblClients)

The relationship between these two tables is based on the ClientID. Now you need to do two things.
  1. In the tblCreditCards table, set the indexed property of the ClientID to Yes (No Duplicates). This will enforce a one to one relationship
  2. click on the relationship in the relationship and tick the referential integrity and cascade boxes.
Mary
Mar 10 '07 #3
xian2
43
Many thank to both NeoPa and Mary for your great advice.

You have been really helpful in the creation of my database and I will undoubtedly return for some more assistance - if you can put up with me that is!

All help is very much appreciated and this is a truly wonderful service.

Best wishes and I hope to be able to help people also in the near future.

Edd
Mar 11 '07 #4
MMcCarthy
14,534 Expert Mod 8TB
You're welcome.

Mary
Mar 11 '07 #5
NeoPa
32,173 Expert Mod 16PB
Many thank to both NeoPa and Mary for your great advice.

You have been really helpful in the creation of my database and I will undoubtedly return for some more assistance - if you can put up with me that is!

All help is very much appreciated and this is a truly wonderful service.

Best wishes and I hope to be able to help people also in the near future.

Edd
That's a great attitude.
We can never have too many experts.
Mar 11 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Ronnie | last post: by
1 post views Thread by MRW | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.