MYSQL Database Defined Relations Problem

Questions and answers regarding general SQL and backend databases

MYSQL Database Defined Relations Problem

Postby JDW » Sat Feb 28, 2004 9:29 pm

Hi,

I'm having a problem where a relationship defined in a MySQL database (via add constraint on a foreign key) is not showing as a Database Defined Relation up when using the 'Create' button in Relations. (All tables are innodb.)

There are several from the same database that are showing up, but that one is not. I've tried several MySQL drivers including the latest alpha.

I don't think it's a problem with the schema.. Any ideas?

Thanks.
JDW
 
Posts: 71
Joined: Sun Feb 01, 2004 1:50 am

Postby Jan Blok » Tue Mar 02, 2004 2:38 pm

Issue confirmed , if the driver does not return the relation info sorted it could happen one is not created, will be fixed in Servoy 2.0 rc8
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby JDW » Wed Mar 03, 2004 7:11 pm

Hi,

Good to hear, I'd like to use Servoy in databases with a large number of foreign key constraints.

Cheers and thanks.
JDW
 
Posts: 71
Joined: Sun Feb 01, 2004 1:50 am

Postby Neale » Thu Mar 04, 2004 6:53 am

Is this likely to be related to http://forum.servoy.com/viewtopic.php?t=987 ?

Thanks,
Neale.
Neale
 
Posts: 230
Joined: Thu May 15, 2003 6:29 am
Location: Australia

Postby Jan Blok » Thu Mar 04, 2004 12:34 pm

The latest mysql driver seems not to have that problem anymore
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby JDW » Fri Mar 05, 2004 8:33 am

Hi,

Yes, the latest MySQL driver did allow db-defined relationships to be discovered and listed in Relations and I was seeing them.

The issue was that not all of them were being displayed. I just tested, and as Jan indicated, this does appear to have been resolved in RC8 and is working as expected.

Cheers.
JDW
 
Posts: 71
Joined: Sun Feb 01, 2004 1:50 am

Postby Neale » Fri Mar 05, 2004 1:49 pm

Indeed - with Connector/J 3.0.11 (previously I had 3.0.9) database relations are detected :-)

Interesting, only one-many relations (i.e. no many-one) were detected. Is this "expected" behaviour?

But not all one-many were detected - presumably that would go away with a Servoy upgrade.

Thanks,
Neale.
Neale
 
Posts: 230
Joined: Thu May 15, 2003 6:29 am
Location: Australia

Postby jcompagner » Tue Mar 09, 2004 6:33 pm

Code: Select all
Interesting, only one-many relations (i.e. no many-one) were detected. Is this "expected" behaviour?


please show me the 2 table create statements (with foreignkey constraints) where you have a one-many and a many-one relations specified...
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby Neale » Wed Mar 10, 2004 3:10 am

OK, I cobbled together a small test case which appears to demonstrate the question. SQL:

Code: Select all
-- Created by dia2sql.pl v1.2-5ntb1 (Wed Mar 10 10:25:25 EST 2004)

--
-- Table structure for table 'parent'
--

CREATE TABLE parent (
   id INTEGER NOT NULL NOT NULL,
   details CHAR(10),
   PRIMARY KEY(id)
) TYPE=INNODB;


--
-- Table structure for table 'child1'
--

CREATE TABLE child1 (
   id INTEGER NOT NULL NOT NULL,
   parent_id INTEGER NOT NULL,
   details VARCHAR(10),
   PRIMARY KEY(id),
   INDEX parent_id_idx (parent_id),
   FOREIGN KEY (parent_id) REFERENCES parent (id)
) TYPE=INNODB;


--
-- Table structure for table 'child2'
--

CREATE TABLE child2 (
   id INTEGER NOT NULL NOT NULL,
   parent_id INTEGER NOT NULL,
   details VARCHAR(10),
   PRIMARY KEY(id),
   INDEX parent_id_idx (parent_id),
   FOREIGN KEY (parent_id) REFERENCES parent (id)
) TYPE=INNODB;


MySQL consumed the above into a new database without complaint.

In developer, created a DB server connection to this database to this DB and a new solution; selected relations and the database under "Database defined relations" and then create pondered and came forth with (only) "db_parent_to_child1" - which looks just fine, but rather lonely.

This is with Servoy 1.2(final), Java 1.4.2_03 on Linux, MySQL Connector/J 3.0.11.

Given the recent fix, I'm not concerned that the "parent_to_child2" relation didn't appear.

But, shouldn't this have created a "child1_to_parent" relation too? Or have I missed something here?

Hopefully I can re-test with Servoy 2.0rc<latest> soon.

Thanks,
Neale.
Neale
 
Posts: 230
Joined: Thu May 15, 2003 6:29 am
Location: Australia

Postby Neale » Thu Mar 11, 2004 8:24 am

With 2.0rc9 both db_parent_to_child1 and db_parent_to_child1 are detected/created :-)

Is there something else we need to do to get the inverse relationships?

Thanks,
Neale.
Neale
 
Posts: 230
Joined: Thu May 15, 2003 6:29 am
Location: Australia

Postby jcompagner » Thu Mar 11, 2004 11:51 am

the database uses those foreignkey constraints both ways so it doesn't have 2 relations for the same thing.

So for both ways we have to do that in servoy itself.. Because our relations can also be globals on the left side our relations can't be 2 ways all the time.. So only for database column relations onle (right and left side)

We will look if we can make this better. (for example look at the db column relations only 2 way or make an easy option where you can generate the invert with one click)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby Neale » Tue Mar 23, 2004 7:41 am

Yes please :-)

a) AFAICS, the db-defined relation defines the child-to-parent and thus implies the parent-to-child. I can't imagine why we wouldn't want both available in servoy.

b) In the case of a manually defined option not involving a Global, a selectable option to automagically create the inverse relationship would be very cool.

Thanks,
Neale.
Neale
 
Posts: 230
Joined: Thu May 15, 2003 6:29 am
Location: Australia


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 30 guests