What is the best way to inherit properties in a tree structure?

I have a simple CMS system that has a simple tree hierarchy:

We have pages from A to E that have the following hierarchy: A → B → C → D → E

All pages are the same class and have a parent-child relationship.

Now, let's say I have a property that I want to inherit among the pages. Let them say that A is red: A (red) → B → C → D → E

In this case, B to E inherits "red".

Or more complex scenarios: A (red) → B → C (blue) → D → E

B inherits red and D / E will be blue.

What would be the best way to solve something like this? I have a tree structure with over 6000 leaves, and about 100 of these leaves have inherited properties. These 100 or so leaves retain their properties in the database. For leaves without explicit properties, I search for ancestors and use memcached to save properties. Then there are overly complex algorithms to handle the expiration of these caches. This is terribly confusing and I would like refactoring to be a cleaner solution / data structure.

Does anyone have any ideas?

Thank!

+5
source share
2 answers

If your problem is performance related ...

, (, , ), .

, , , HTML DOM CSS, :

  • node ( )
  • - ( , ),
  • ,
  • ,
  • , , , ,

, . , Windows Presentation Foundation DependencyProperty.

...

, (, , ), - . , , , .

, , , node , . "1.2.1.3.4" 6- . , , . SQL.

+1

, , RDF/RDFS. RDF W3C (, , ) URI; RDFS, , . , , .

, , Lion Animal programmer Geek, :

doc:lion rdf:type class:mamal .
doc:programmer rdf:type class:Geek .

, - , - .

class:mamal rdfs:subClassOf class:animal .
class:animal rdfs:subClassOf class:LivingThing .

, - :

class:geek rdfs:subClassOf class:human .
class:human rdfs:subClassOf class:LivingThing .

, SQL, SPARQL , , , :

SELECT * WHERE {
       ?doc rdf:type class:LivingThing .
}

?doc - , class:LivingThing. doc:lion doc:programmer, RDFS, , , , doc:lion doc:programmer class:LivingThing.

:

SELECT * WHERE {
       doc:lion rdf:type ?class .
}

, doc:lion rdf:type of class:mamal class:animal class:LivingThing.

, , RDFS :

doc:programmer doc:studies doc:computerscience .
doc:lion doc:instint doc:hunting .

, doc:skill doc:instint - doc:knows:

doc:studies rdfs:subPropertyOf doc:knows .
doc:instint rdfs:subPropertyOf doc:knows .

:

SELECT * WHERE {
       ?s doc:knows ?o .
}

, , .

RDF/RDFS , , . Java, Jena, .Net lije Python RDFLIB

, CMS, , , RDF. Drupal, , (. http://drupal.org/project/rdf

+1

All Articles