Jump to content
xisto Community
logophobia

Mysql Relational Problems

Recommended Posts

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

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

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. :rolleyes:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.