| List: | General Discussion | « Previous MessageNext Message » | |
| From: | Colin Bull | Date: | May 27 2004 7:42am |
| Subject: | Re: Foreign Key Constraints | ||
| View as plain text | |||
kyuubi@stripped wrote: >Hi, I am trying to use the foreign key constraints from InnoDB >and creating indexes is a requirement for foreign key. >The problem is that by creating index for my foreign key, >it does not allow my foreign key to have null or blank values which my records will > have. >For eg. a BorrowerID is a foreign key on a Book table, but when the book is not > borrowed, >the BorrowerID will be null and I can't seem to import the data containing null values > for the foreign key. >Is there a way to solve this? >Thanks. > > > > > I think you have missed the point of a foreign key constraint. It is to ensure referential integrity. A constraint stops you doing things, ie entering a value that does not exist in another table. Or create a borrower called NO-ONE and always change the borrower to this when a book is returned. Or just use an outer join on an indexed field when doing reports is easiest and no constraint. Colin Bull
| Thread | ||
|---|---|---|
| • Foreign Key Constraints | kyuubi | 27 May |
| • Re: Foreign Key Constraints | Jeff Smelser | 27 May |
| • Re: Foreign Key Constraints | Colin Bull | 27 May |
| • Re: Foreign Key Constraints | Robert J Taylor | 27 May |
| • Re: Foreign Key Constraints | Martijn Tonies | 27 May |
| • Re: Foreign Key Constraints | Jeff Smelser | 27 May |
| • Re: Foreign Key Constraints | Martijn Tonies | 27 May |
| • Re: Foreign Key Constraints | Martijn Tonies | 28 May |
| • Re: Foreign Key Constraints | Jeff Smelser | 28 May |
| • Re: Foreign Key Constraints | Martijn Tonies | 28 May |
| • Re: Foreign Key Constraints | Michael Stassen | 28 May |
| • Re: Foreign Key Constraints | Michael Stassen | 28 May |
| • Re: Foreign Key Constraints | Martijn Tonies | 28 May |
| • Re: Foreign Key Constraints | Jeff Smelser | 28 May |
| • Re: Foreign Key Constraints | Jeff Smelser | 28 May |
| • Re: Foreign Key Constraints | Martijn Tonies | 28 May |
| • Re: Foreign Key Constraints | SGreen | 27 May |
