Help with database planning
Rob Williscroft
rtw at freenet.co.uk
Sat Nov 14 16:14:50 EST 2009
Juliano wrote in
news:0e64893a-af82-4004-bf3c-f397f2022846 at g22g2000prf.googlegroups.com
in comp.lang.python:
[snip]
> So, for ONE *concept*, we have, usually, MANY *slots*, each *slot* has
> ONE *facet*, and each *facet* can have MORE THAN ONE *filler*.
> Besides, some *slots* and *fillers* are themselves *concepts*,
> creating a sort of recursive reference.
What I'm grokking from the data you show is that a "Concept" is
a table (or a python class), "slots" are attributes of the concept
and facets are the type of "slot", finally the "fillers" are
(mostly) the data.
But also you seem to have "slots" that represent relationships
between "Concepts" and other tables, in this case the "slots"
should be tables.
For example with the slot type "INSTANCE-OF", what is
"OTHER-NIGER-KORDOFANIAN-LANGUAGE" is it another concept or a
list of concepts or a concept "OTHER-NIGER-KORDOFANIAN" and
a type "LANGUAGE", I suspect you have a table "Language"
and also an table "Region" in there too.
It may be time to start thinking in terms of what you are
modeling and what the entities are (as apposed to trying to
convert the data you have), once you have that, work out
how to load that data from your current file and check
that you can query your model correctly.
Maybe something like (using a made up ORM):
class Concept:
name = TextField()
definition = TextField()
primary_key = PrimaryKey( name )
class IsASlot:
concept = ForeignKey( Concept )
is_a = ForeignKey( Concept )
primary_key = PrimaryKey( concept, is_a )
class LexeSlot:
concept = ForeignKey( Concept )
value = TextField()
primary_key = PrimaryKey( concept, value )
class Region:
region = TextField()
primary_key = PrimaryKey( region )
class Language:
language = ForeignKey( Concept ) # or is it TextField() ?
primary_key = PrimaryKey( language )
class LanguageOfSlot:
language = ForeignKey( Language )
region = ForeignKey( Region )
primary_key = PrimaryKey( language, region )
To reiterate, you should use your domain expertise to create
the model.
>
> <begin table>
> line_no concepts slots facets fillers
> -----------------------------------------------------------------------
> ------- 00000 ABANDON DEFINITION VALUE "to leave or
> desert something or someone"
> 00001 ABANDON IS-A VALUE EXIT
> 00002 ABANDON LEXE MAP-LEX "leave behind-V1"
> 00003 ABANDON LEXE MAP-LEX abandon-V1
The "-V1" in the above looks worryingly like you have structure embedded
in the data field, if so you should extract is so its in its own field
or table.
> (...)
> 97420 ZULU DEFINITION VALUE "a language or dialect
> spoken in south africa and others"
> 97421 ZULU INSTANCE-OF VALUE
> OTHER-NIGER-KORDOFANIAN-LANGUAGE
> 97422 ZULU LANGUAGE-OF INV LESOTHO
> 97423 ZULU LANGUAGE-OF INV SOUTH-AFRICA
Rob.
More information about the Python-list
mailing list