Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Mysql Relational Problems
timstokman
post Dec 14 2004, 07:09 PM
Post #1


Member [Level 2]
*****

Group: Members
Posts: 86
Joined: 19-October 04
From: Alkmaar, the netherlands
Member No.: 1,832



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 it

How 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.
Go to the top of the page
 
+Quote Post
eiteljoh
post Dec 16 2004, 01:40 AM
Post #2


Advanced Member
*******

Group: Members
Posts: 101
Joined: 3-December 04
Member No.: 2,521



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:

QUOTE
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

Go to the top of the page
 
+Quote Post
timstokman
post Dec 16 2004, 03:55 PM
Post #3


Member [Level 2]
*****

Group: Members
Posts: 86
Joined: 19-October 04
From: Alkmaar, the netherlands
Member No.: 1,832



Thx, ill try that.
Go to the top of the page
 
+Quote Post
bjrn
post Jan 9 2005, 12:24 PM
Post #4


Super Member
*********

Group: Members
Posts: 378
Joined: 8-January 05
Member No.: 3,174



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. wink.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Mysql Downtimes...(39)
  2. A Lot Of Problems(10)
  3. I Hate Dial-up Arghhhhhhh(61)
  4. Linking To Mysql From Vb(7)
  5. Help Moving Mysql Files To A New Host(2)
  6. Guy Problems(37)
  7. Can You Add Images Into A Mysql Database?(21)
  8. Razr Problems(21)
  9. New Type Of Hard Drive That Could Solve Data Problems(5)
  10. Dell Computer Problems Need Help.(8)
  11. Firefox Problems theme or addon diabled(3)
  12. Problems With The Sony Ericsson S500?(10)
  13. Advice On Girl Problems(4)
  14. Yahoo Messenger 9.0 Is Out(2)
  15. Mysql Won't Update(5)
  1. Mysql Hacks(6)
  2. Download Statusbar Extension For Firefox Causing Problems(2)
  3. Having Problems Connecting To The Internet Etc. On Another Laptop(2)
  4. Vb And Mysql(3)
  5. Mysql Server Down(10)
  6. Mccodes With Mysql! [resolved](6)
  7. Website Structure(3)
  8. Php Myadmin(6)
  9. How To Connect Mysql With Jsp ?(4)
  10. Ear Problems?(3)
  11. Lots Of Problems.. Emergency(2)
  12. Beginning Php And Mysql: From Novice To Professional, Third Edition Review(1)
  13. Big Problems With Computinghost(3)


 



- Lo-Fi Version Time is now: 22nd November 2008 - 01:47 AM