Nullable Foreign Keys

Posts   
 
    
shware
User
Posts: 23
Joined: 14-May-2007
# Posted on: 14-May-2007 17:33:20   

Hi,

Is there an option which allows the designer to map a foreign key relationship on nullable columns?

This an existing database which allows 2 tables to be related, but it's not a forced relationship. I'm working around this by modifying the development database but am wondering if there's an option setting that I'm missing somewhere.

Evaluating the product - very nice so far!

Thanks!

Shawn

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-May-2007 07:48:36   

Hi Shawn. Good to hear another person evaluating this great tool.

About your question. Do you want to create a Custom Relation in the designer (LLBLGenPro Help - Using the designer - Adding custom relations) and the FK side is a nullable field? Is there actually an DB relation at this tables? what kind of relation?

What template set are you using (SS or Adapter)? What LLBLGenPro version are you evaluating?

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39914
Joined: 17-Aug-2003
# Posted on: 15-May-2007 10:39:45   

FK fields can be nullable though the PK side has to be a PK. Is that the case in your situation?

Frans Bouma | Lead developer LLBLGen Pro
shware
User
Posts: 23
Joined: 14-May-2007
# Posted on: 15-May-2007 22:22:22   

Hi,

Thanks for the responses.

No, the FK is not part of the FK.

It's a little strange and I think it's some sort of catalog refresh issue. Every now and then fields are not included in the available dropdowns for foreign key fields. The first time I saw this I assumed it was a nullable issue and changed the fields on my dev database and did a refresh. Then the field would "show up" in the list of available foreign keys. So I thought it was indeed a nullable issue.

Now, there are more of the tables included in the project catalog and I am seeing nullable fields available as foreigh key selections which indicates some other sort of issue. I've seen similar behaviour when creating sub-types and trying to pick the discriminator column.

I'm new to the product so may be missing a basic step.

As mentioned in another thread, I'm modeling a popular open-source CRM application (SugarCRM) because it's a very real world example I'm familiar with. In the modeling process I've not had to do anything "custom" except add tables to the catalog, build sub-types where needed, and create appropriate relationships. Most of the main modules have been mapped in about a day.

Since my LGP project is based on an open source data model, I'd be happy to share the final LGP file, if interested. I'm now starting to model the base security model (users / roles / module ACLs / record audits). I think the relationships are straightforward, but filtering data at the entity level and generating field-level change audit entries is something that may take me a bit to figure out. Any pointers in these areas (like what part of the manual to read) would be greatly appredicated simple_smile

Again, thanks for the response. The responsiveness on this forum is indeed impressive.

Shawn

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 16-May-2007 10:44:50   

No, the FK is not part of the FK.

I think Frans ment that the PK field in a relation must be a PK (marked as a PK in the designer) and not any other field.

It's a little strange and I think it's some sort of catalog refresh issue. Every now and then fields are not included in the available dropdowns for foreign key fields. The first time I saw this I assumed it was a nullable issue and changed the fields on my dev database and did a refresh. Then the field would "show up" in the list of available foreign keys. So I thought it was indeed a nullable issue.

I think there is no limitation on the fields list of FK except to match the type of the selected PK.

Since my LGP project is based on an open source data model, I'd be happy to share the final LGP file, if interested.

Sure it would be nice. Please post it on the Showcases Forum.

I think the relationships are straightforward, but filtering data at the entity level and generating field-level change audit entries is something that may take me a bit to figure out.

A built-in Audit functionality will be available in the next free-upgrade of v.2 But if you want to build it using the current version, please check the following thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3612