View Single Post
  #7 (permalink)  
Old July 1st, 2009, 05:00 AM
peace95 peace95 is offline
Friend of Wrox
Points: 793, Level: 10
Points: 793, Level: 10 Points: 793, Level: 10 Points: 793, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default FOREIGN KEY NOT INPUT IN TABLE FROM VB.NET

Slake:

Thanks for the detail. One of your problems is due to the fact the relationship is not correct. What if the book is read, or bought by more than one Customer? In my opinion, the relationship between your Customer and your Book tables are many-to-many. You need a junction table:
Code:
 
CustTbl( C_id, CName, CAddress)---<CustBkTbl(CusBkID,C_id,B_id)>----BkTbl(B_id,....)
 
In the Book Table I removed the C_id and placed it in the junction table, CustBkTbl. The junction allows for the Customer to buy/read 1 or more books and it allows for the 1 or more Books to be read/bought by more than one Customer. The -----< & >----- indicates the relationships between the 3 tables.
Another situation I see in your Book Table is with the Author in that you may have more than 1 author per book....as in many WROX books, for example. To rectify that build the following::
AuthorTbl (authorID, author name) and AuthorBookTbl(aubkID, authorID,B_id), which is the junction table for Author and Book, the BkTbl(B_id,Title, ISBN).

Remember: "....The KEY is the KEY', from 70's movie Jumpin' Jack Flash

Hope this hellps.
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.

Last edited by peace95; July 1st, 2009 at 05:33 AM..
Reply With Quote