[ale] Organizing data

Jason Etheridge phasefx at magusaptus.com
Wed Apr 28 08:09:11 EDT 2004


Chris Fowler wrote:
> The problem is that the first row has an identical row after it with the
> exception of user id and email.  That is where the extra stuff comes
> from.  The unique key that I will reference is the alarm_id and so there
> are 5 rows of the same alarm_id.  In the alarm table there is only one
> alarm_id but when you start grabing data from all over the database that
> has relationships then you end up with more than one row for a single
> alarm  in the example at http://www.linxdev.com/out.html I need to
> condense the first 5 rows of alarm 4 into a single data structure.  Then
> The same for 5, 6, 7, etc...  

So your main concern is eliminating data redundancy?  And you don't want 
to just mimic the tables with hashes and arrays?  I'm not sure I'm 
following you right.

> In the database there are many mapping tables.  There is 
> on mapping table that will map a user into an escalation_group.
> There there is a mapping table where we map an escalation_group into
> a larger group called a notification group.  With the mapping tables
> there is no way of knowing how many users are in an escalation_group and
> how many escalation_groups are in a notification_group.  Location_id and
> nottification_group_id is a 1 to 1 relationship.  There is no mapping 
> for them (yet).

escalation_id = escalation_group_id?

Maybe something like:

while ( ($alarm_id,
	$trigger_match,
	$console_id,
	$location_id,
	$notification_group_id,
	$escalation_id,
	$user_id,
	$user_email) = $sth->fetchrow_array ) {

	// FOR LOOKUPS BASED OFF USER
	$user{ $user_id }{ 'email' } = $user_email;
	push @{ $user{ $user_id }{ 'escalation_id' } }, $escalation_id;
	push @{ $user{ $user_id }{ 'notification_group_id' } },
		$notification_group_id;
	push @{ $user{ $user_id }{ 'alarm_id' } }, $alarm_id;

	// etc. for trigger, console, location

	// FOR ESCALATION GROUP LOOKUPS
	push @{ $escalation_group{ $escalation_id } }, $user_id;

	// FOR NOTIFICATION GROUP LOOKUPS
	$notification_group{ $notification_group_id }{ $escalation_id }
		= \@{ $escalation_group{ $escalation_id } };

	// FOR ALARM LOOKUPS
	$alarm{ $alarm_id }{ $notification_group_id }
		= \%{ $notification_group{ $notification_group_id } };

}

That's a syntax nightmare for accessing, though. :-/

I'd keep everything in some sort of SQL database if I could, even if it 
was just a dump of the data accessed through DBI::CSV.

-- Jason



More information about the Ale mailing list