logophobia 0 Report post Posted December 14, 2004 didn't know where to post this but since I build this database with php, I post it here.I have to build a relational database 4 a school project. Made a webbased interface and made a database with primary&foreign keys and not null fields to preserve the integrety of my database.-When I insert an empty field or I just don't give the field where the field has the property NOT NULL it just fills in nothing or some default value (it ignores the not null property).-When I insert 2 rows with the same primary key in the same table it doesn't throw an error but just inserts it-When I insert data in a field with a foreign key with a value that doesn't match the field it refers to then it doesn't throw an error but just accepts itHow can I force mySQL to throw errors when these situations occur? This way the whole concept of relational database is useless. Thx in advance 4 any help. Share this post Link to post Share on other sites
eiteljoh 0 Report post Posted December 16, 2004 Not sure which version of mysql you are running, but anyways, mysql defaults to try to do a "best guess" for you, instead of throwing an error. for example, a "not null" integer field, when a null value inserted, will put a '0' in there for you. anyways, see doco for Configuration Options ... but here's some quick info: You can configure MySQL not to use DEFAULT column values for non-NULL columns (that is, columns that are not allowed to be NULL). See section 1.8.6.2 Constraint NOT NULL and DEFAULT Values. shell> CXXFLAGS=-DDONT_USE_DEFAULT_FIELDS ./configure Share this post Link to post Share on other sites
logophobia 0 Report post Posted December 16, 2004 Thx, ill try that. Share this post Link to post Share on other sites
bjrn 0 Report post Posted January 9, 2005 I remember that a few years ago MySQLs philosophy was that the relationships were the responsibility of the application, not of the database. Meaning that the integrity had to be checked by the app.Seems like they've changed it now. Which is nice. Having to check integrity with your application was a major annoyance. Share this post Link to post Share on other sites