getSize()

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

getSize()

Postby patrick » Wed Jul 28, 2004 5:47 pm

Hello,

I have a table with group_names and a table with groups. In groups I save a bunch of record IDs for a given group_name. Now I want to be able to tell the user, how many entries there are for a single group_name (so doing a count(*)).

I have a field member_count that uses getSize over the relation to groups. That gives me 40 every time a group has more than 40 members. In formulas I don't have access to the DatabaseManager, so I can't do a count (*).

The only way I see right now is to run a method onShow of the groups form, that retrieves the counts for all groups and then walks through the groups and inserts this value manually. That is not so nice.

Any ideas?

A nice enhancement would be if we could use aggregations on relations!

Thanks, Patrick

P.S. I know you Servoyans don't like those "expensive" operations, but sometimes they are useful and if it takes too long it's not your fault, is it?
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby Odysseus » Wed Jul 28, 2004 6:04 pm

Hmm, if I understand you correctly, I think I ,quite innocently, just did what you say can't be done :)

I have table assignmets and table mtomStudents.
So an Assignment can have many students. In order to see how many students where given an assignment i :

define the relation Assignment.ID to mtomStudents. ass_id (couldn't resist that one)

1) defined an aggregation (count PK in students) field in mtomStudents
2) placed in a form based on Assignment the aggregation field

and presto

functioning without problem


HTH
Odysseus

Citizen of Old Europe
Odysseus
 
Posts: 205
Joined: Wed Sep 10, 2003 9:34 pm
Location: Belgium

Postby patrick » Wed Jul 28, 2004 6:23 pm

thanks. that works.

I still think that aggregations over relations would be nice. Because what we do here is actually a bit confusing...
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby Odysseus » Wed Jul 28, 2004 6:27 pm

I think that's the part of your mail I'm not understanding.

Isn't the solution I gave "working over relations" ?

Please enlighten me

THX
Odysseus

Citizen of Old Europe
Odysseus
 
Posts: 205
Joined: Wed Sep 10, 2003 9:34 pm
Location: Belgium

Postby patrick » Wed Jul 28, 2004 6:58 pm

Yes, of course. But basically the information you want reads like this:

Give me the count of a related set.

So you would go to the table of the left side of your relation, go to aggregations, hit new and select count(relation.field). That's it.

That's what I meant.
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby Odysseus » Wed Jul 28, 2004 9:44 pm

aha , I sea what you mean. :idea:

but, I think that your solution would be "weaker", not stronger.

If I read you correctly, your "related" aggregation would only work over the relation for which you created it.

The way it is now the aggregation will work over "any" relation that involves the many table
Odysseus

Citizen of Old Europe
Odysseus
 
Posts: 205
Joined: Wed Sep 10, 2003 9:34 pm
Location: Belgium

Postby patrick » Thu Jul 29, 2004 1:11 am

I am not saying that we should take one solution for the other... Both are useful :wink:
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 27 guests

cron