Miguel: First: Be more specific. Did you have an expression in mind? Second: Yes, use InnoDb tables to enforce referential integrity. See the URL (below) for information on InnoDb table usage. Regards, Adam InnoDb in MySQL -> http://www.mysql.com/doc/en/InnoDB.html <http://www.mysql.com/doc/en/InnoDB.html>
-----Original Message----- From: Miguel Ernesto [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 07, 2003 12:57 PM To: [EMAIL PROTECTED] Subject: Check (expr) Syntax and/or other fields checks Hello everyones, Did somebody know: First: What kind of expr it is allowed on the check condition on: create table syntax? Second: Is it posible to force conditional FOREIGN KEY checks? for example: We make One table who have one UNIQUE Key and one special condicion: TRUE or FALSE. Then we create a second table who refers one field to the FOREIGN key table ... but we got that there are 1 or 2 posible values for each row on the FOREIGN table: 'the foreign key + true' and 'the foreing key + false' for each row, but we want to allow just 2 posible values when the foreign key condition its set to TRUE, and only 1 when its set to false. And we want be completly sure that just the correspondings values are entered on the second table. Example: First table: Primary key field: SKU+Special_Condition SKU Special_Condition Allow A-1 FALSE JUST one value with this SKU on the foreign table B-1 TRUE 2 values with this SKU on the foreign table: 'B-1: FALSE' and 'B-1: TRUE' Second table: Foreign key field: SKU+Special_Condition SKU Special_Condition Integrety_check A-1 TRUE Refuesed!: not valid value A-1 FALSE Ok! B-1 TRUE Ok! B-1 TRUE Ok! Why do I need this? 1. I have a series of rows who can take one or more values depending on a special condition who much be specified first. 2. I need to choose a specific field depending on the special condition given, 3. I do not want to allow to enter special conditions on the foreign table who are not allowed the primary table, and 4. Later I'm going to retrieve that specific value, based on the special condition given Example: SKU Special_Condition Value1 Value2 A-1 FALSE 10 null B-1 TRUE 20 30 C-1 TRUE 10 20 As you can see: - I would like to retrieve from A-1 just Value1 because the special condition just allow the first value - I would like to retrieve from B-1 or C-1 Value1 or Value2 because the special condition allow both values Any Idea? A BETTER LIFE, starts with the best and more exclusive products for HEALTH, BEAUTY and HOME, the Sweet 16 by <http://www.quixtar.com/> Quixtar. Miguel Ernesto Pérez Cabrera Independent Businnes Owner IBO# 1066703 ___________________________________________________________________ For more professional information, please go to: <http://www.quixtar.com/> Quixtar and <http://www.pronetvirtual.com/> Pronet and contact me: at <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED], or call me now at (809) 530-3433. If you have not visited yet, go to <http://www.pronetvirtual.com/> Pronet choose the region or country closest to you, register like guest, and post a comments about what was that who get more interesting to you.