Subject | Re: Design question for "attributed instances" |
---|---|
Author | tdtappe |
Post date | 2005-10-22T13:37:26Z |
Hi Ali,
non-native-english-speakers ;-)
But this still does not seem to address the problem of attributes
"with values", right? It's not only that I would like to find (or
store) some object that has "this" and "that" attribute. There should
also be a "value" for that attribute.
Like the attribute itself is something like "USERNAME" and
"COMPUTERNAME". And I am not only looking for objects (instances of
category) that have these attribute "USERNAME" and "COMPUTERNAME". But
these attributes have to have some specific "value". Like "HEIKO" for
USERNAME and "PC01" for COMPUTERNAME.
How to solve this problem with your design?
--Heiko
> Hi Heiko,Yeah - same with me. Isn't it sometimes hard for us
> Sorry it was my fault about my perfect(!) english knowladge plus
> unstable-fast OCR of my brain.
non-native-english-speakers ;-)
> > Where for instance is the attribute value?Yes - now I probably know what you mean.
> > How would you search for an "instance" of a category
> > with specific attribute values?
>
> select name
> from item
> where cat_id=:selected_cat_id
> and att_id in (:selected_att_id1,:selected_att_id2 ...)
>
> My design was most flexable, you can define any item with any
> catagory and attribute combination.
>
> your examples was about each items have only one catagory and
> attribute.
>
> if your object items have more than one category or attributes,
> then you need to define other referance tables..
>
>
> CREATE TABLE CATEGORY (
> ID INTEGER PRIMARY KEY ,
> NAME VARCHAR(64) NOT NULL UNIQUE
> );
>
> CREATE TABLE ATTRIBUTE (
> ID INTEGER PRIMARY KEY,
> NAME VARCHAR(64) NOT NULL UNIQUE
> );
>
> CREATE TABLE CATEGORY_ATRIBUTE (
> ID INTEGER PRIMARY KEY,
> CAT_ID INTEGER NOT NULL REFERENCES CATEGORY(ID),
> ATT_ID INTEGER NOT NULL REFERENCES ATTRIBUTE(ID),
> UNIQUE(CAT_ID,ATT_ID)
> );
> -- You can predefine category-attribute relations with this table
> to force usage of them
>
> CREATE TABLE OBJECT (
> ID INTEGER PRIMARY KEY,
> NAME VARCHAR(64) NOT NULL UNIQUE
> );
>
> CREATE TABLE OBJECT_DETAIL (
> ID INTEGER PRIMARY KEY,
> OBJECT_ID INTEGER NOT NULL REFERENCES OBJECT(ID),
> CAT_ATT_ID INTEGER NOT NULL REFERENCES CATEGORY_ATTIBUTE(ID)
> );
>
> CREATE TABLE ITEM (
> ID INTEGER PRIMARY KEY,
> OBJECT_ID INTEGER NOT NULL REFERENCES OBJECT(ID),
> NAME VARCHAR(64) NOT NULL UNIQUE
> );
>
>
> You can do what you want to do with this tables.
But this still does not seem to address the problem of attributes
"with values", right? It's not only that I would like to find (or
store) some object that has "this" and "that" attribute. There should
also be a "value" for that attribute.
Like the attribute itself is something like "USERNAME" and
"COMPUTERNAME". And I am not only looking for objects (instances of
category) that have these attribute "USERNAME" and "COMPUTERNAME". But
these attributes have to have some specific "value". Like "HEIKO" for
USERNAME and "PC01" for COMPUTERNAME.
How to solve this problem with your design?
--Heiko