tags:

views:

53

answers:

4

Let's say I'm making a program for an English class. I'd like to store data in this way:

ID      Object
0       Present Tense
1       1st person singular
2       To Be
3       I am

How can I retrieve the value for ID 3 based on IDs 0-2? The only thing I can think of is:

ID      Object     FromIDs
3       I am       0,1,2

The problem with this is that I'd have to do a fulltext index and I think this table is going to get pretty large. I don't want separate tables for different types of objects, if possible, because I don't know what I'll end up doing with these objects and I want as much flexibility as possible. I could have a second table relating IDs to each other, but I've only done that successfully relating a column from one table to a column to another.

Thanks in advance!

A: 

You need to break the data into different tables. Have a table that stores the "tense" and another that stores the type "1st person singular".

sparkkkey
A: 

Can you explain your problem a little more. From what you have I'm not sure if you're trying to go down the path of Entity-Attribute-Value or probably what is more likely is that relational database is not a good fit for your problem; you may need to use some sort of tree data structure. If you update, I can try to provide a better answer.

BobbyShaftoe
The basic problem is that in what I'm making there is no differentiation between an attribute and a value. Some values are just values and some attributes are just attributes, but most values are attributes and vice versa. For instance, "Present" is both a tense and a word that I might want to relate to in a different way. I'm trying to avoid data entry complexity by designing the database in a flexible and simple way.
Stephane
Oh and I guess I am looking for a tree structure but with the ability to have leaves of one branch be the main branch elsewhere.
Stephane
A: 

What I've decided to do is a combination of what was suggested and what I originally thought. I'm going to have a master list with IDs that are auto-incremented and copied to other tables. That way, I have properties of different parts of speech separated, but still have everything relating to everything else.

Stephane
A: 

This is really not a good fit for a relational database. Sorry, you're trying to drive a nail using a screwdriver.

When you have no distinction between an attribute type and a value, you're modeling semantic data. The open standard for this type of data modeling is RDF.

Bill Karwin