If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > use of Check constraint in data validation rules

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-14-08, 00:51
arpita_ece07 arpita_ece07 is offline
Registered User
 
Join Date: Mar 2008
Posts: 5
use of Check constraint in data validation rules

I have two table:
NodeTable
MetaNOdeTable

NodeTable
----------------------------
NodeId :1
NodeType:Tools (This NodeId & NodeType are column)

MetaNodeTable
-------------------------
NodeId:1
SubType: Process (This NodeId & SubType are column)


Here NodeId ofboth the table are the primary key of that table.There is no FOREIGN Key between this two table.
But there is a validation rules between this two table...i.e. the SubType of MetaNodeTable depends on the NodeType of NodeTable
Example: If the NodeType of NodeTable is "Tools" the the SubType of MetaNodeTable will be "Process".

My quwestion is how I can put this validation at the time of data load.Can check constraints work for this?How can I put a constraint for this validation which?
I have to put the validation such a way that it will show the constraint violation if I try to insert any wrong data.....

Please help me.....I am waiting for ur reply.....

Last edited by arpita_ece07; 03-14-08 at 00:56.
Reply With Quote
  #2 (permalink)  
Old 03-14-08, 11:09
tianmingqing tianmingqing is offline
Registered User
 
Join Date: Feb 2005
Location: Utah
Posts: 73
It seems like you are trying to create an implicit relationship between Nodes and MetaNodes. In that case, the best thing to do is make that relationship explicit by using foreign keys. You should not be relating the primary keys of two tables. You need to look at your tables and decide which is true

1. Nodes have one or more MetaNodes.
OR
2. MetaNodes have one or more Nodes.
OR
3. Nodes have one or more MetaNodes and MetaNodes have one or more Nodes.
4. Nodes have one and only one MetaNode and MetaNodes have one and only one Node.

Each of these relationships will require a different structure for your tables, so what kind of relationship do you have between the tables?
__________________
Dandy
Aspiring Database Dwarf
Reply With Quote
  #3 (permalink)  
Old 03-17-08, 03:46
arpita_ece07 arpita_ece07 is offline
Registered User
 
Join Date: Mar 2008
Posts: 5
ONe to One relationship is there between NodeTable and MetaNodeTable because only one record can be there in the MetaNodeTable which is corresponding to NodeTable.
Reply With Quote
  #4 (permalink)  
Old 03-18-08, 13:10
koriba koriba is offline
Registered User
 
Join Date: Mar 2008
Location: Windhoek Namibia
Posts: 13
If your relationship is one2one handle the table as one. i.e. make one table
__________________
Wayne Philip - openaxon.com
Reply With Quote
  #5 (permalink)  
Old 03-18-08, 13:30
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
Just be careful with the CHECK constraint, I don't think you can get it to work.. You can check here for the full details, but:
Quote:
Originally Posted by My SQL 6.0 Documentation
The CHECK clause is parsed but ignored by all storage engines
I've heard that there is an option that can be set to forewarn a user about syntax that MySQL will happily parse but never execute/enforce, but I can't find that option anywhere.

-PatP
Reply With Quote
  #6 (permalink)  
Old 03-18-08, 22:24
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
server sql mode: http://dev.mysql.com/doc/refman/5.0/...-sql-mode.html

didn't see anything about the silent CHECK clause, though

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 03-19-08, 08:49
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Whats a metanode?
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On