Data structure suggestions
Data structure suggestions
- Subject: Data structure suggestions
- From: Andre Masse <email@hidden>
- Date: Tue, 21 Oct 2008 14:53:44 -0400
Hi all,
I'm currently implementing front-end to create a sql query for a
PostgreSQL database. I have:
- a popup (tableMenu) menu containing the database' tables which is
populated the database (from pg_tables)
- a combobox (fieldsList), datasource is an array of "query-able"
fields. I'm currently using the database fields names but I will need
to provide more user friendly names ("Last Name" instead of lname).
- a combobox (operatorsList), datasource is an array of query
operators (in plain text) which is dependant on the field's type.
Example: for a date type, operatorsList will contain "is", "is
before", "is after", "is not" and for a string type "is", "begins
with" etc
- a text field (queryValue) which is also dependant on the field's
type (quotes for strings, adding the '%' wildcard for "begins with" etc)
For each table I need
- the "query-able" field's list (not all fields should be exposed for
queries) using the database fields names
- another one for the user friendly names
- another one for the fields types
and for each field type
- an operator list in plain text
- another for the sql version
- some kind of flags for quoting the value or not, inserting a
wildcard or not...
I've already done the user friendly part (for 2 tables) using numerous
arrays and dictionaries.
Here's what I'm doing at this point:
- user selects "Person" in the table popup.
- populate the fieldsList combo by looking up in an NSDictionary
which keys are table names and values are an array of fields belonging
to the Person's table.
- populate the operatorsList combo by first getting the field's
type from an NSDictionary who's mapping the field's name to its type
and then looking up in another dictionary who's mapping a type to an
operator array.
Now, I could continue using the same pattern but I'm pretty sure I'll
get problems understanding myself a month from now... I'm already
having trouble making myself clear in this message :-) Not counting
the fact that the database contains 50+ tables!
Any ideas?
Thanks,
Andre Masse
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden