Monday, March 26, 2012

Relational Database design problem

Hi,

I have a very important question about the database design. Suppose that I have a table named as tblPerson with the following Fields.

tblPerson:
--------
PersonID
PersonName

And I have a another table that has the Person Credit card Information:

tblPersonCreditCard:
---------

CreditCardID
PersonID
CreditCardTypeID

And Another table which contains the type of creditcards:

tblCreditCardsType:
----------

CreditCardTypeID
CardName

NOTE: Suppose CreditCardTypeID 1 = "MasterCard", 2 = "Visa" , 3 = "platinum"

Now if a person suppose "john" has three credit cards then it will be stored as.

tblPersonCreditCard:
---------

CreditCardID PersonID CreditCardTypeID
1 1 1
2 1 2
3 1 3

Each if the number belong to one Field.

Which means that "john" has three credit cards

Now as u see that in tblPersonCreditCard john's id, which is 1 is repeating 3 time. how can I design a database in which the id does not repeat. I have heard that this can be done by using the bitwise operator but HOW.

thanks in advance,

AzamI don't see a problem with each record in tblPersonCreditCard including a foreign key to the credit card's owner. Is there some problem you're having with doing so?|||No i am not having any problem. But I just wanted to know that if there a better way of doing the same thing.|||There is no reason to do what you are attempting to do. To create a many-to-one relationship, you need to have a foreign key which will potentially repeat in the child table.|||I have heard that you can use some sort of the bit wise operator to store all the relationship of the person in a single field. I have no idea how ??|||I think you mean "bitmask", actually. Here'san article, if you're really interested.

No comments:

Post a Comment