Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4041794
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:55:30+00:00 2026-05-20T12:55:30+00:00

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

  • 0

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

We have pages A through E that has the following hierarchy:
A -> B -> C -> D -> E

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

Now, let’s say I have a property I want inherited among the pages. Let’s say A is red:
A (red) -> B -> C -> D -> E

In this case, B through E would inherit “red”.

Or a more complex scenarios:
A (red) -> B -> C (blue) -> D -> E

B would inherit red, and D/E would both be blue.

What would be the best way to solve something like this? I have a tree structure with over 6,000 leafs and about 100 of those leaves have inheritable properties. Those 100 or so leaves have their properties saved in the database. For leaves without explicit properties, I look up the ancestors and use memcached to save the properties. Then there are very overly-complex algorithms to handle expiring those caches. It’s terribly convoluted and I’d like refactor to a more cleaner solution / data structure.

Does anybody have any ideas?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:55:31+00:00Added an answer on May 20, 2026 at 12:55 pm

    If your problem is performance-related…

    I assume you’d want to save on memory of all these inheritable properties (or perhaps you have a lot of them), otherwise this can be trivially solved with virtual properties.

    If you need sparse inheritable properties, say if you are modelling how HTML DOM properties or CSS properties propagate, you’ll need to:

    1. Keep a pointer to the parent node (for walking upwards)
    2. Use a hash dictionary to store the properties inside each class (or each instance, depending on your needs), keyed by name
    3. If the properties don’t vary by instance, use a class-static dictionary
    4. If the properties can be overridden instance-by-instance, add an instance dictionary on top
    5. When accessing a property, start finding it at the leaf, look in the instance dictionary first, then the class-static dictionary, then walk up the tree

    Of course you can add more functionalities on top of this. This is similar to how Windows Presentation Foundation solves this problem via DependencyProperty.

    If your problem is database-related…

    If instead your problem is to avoid reading the database to walk up the tree (i.e. loading the parents to find inherited properties), you’ll need to do some sort of caching for the parent values. Or alternatively, when you load a leaf from the database, you can load all its parents and create a master merged properties dictionary in memory.

    If you want to avoid multiple database lookups to find each parent, one trick is to encode the path to each node into a text field, e.g. “1.2.1.3.4” for a leaf on the 6th level. Then, only load up nodes that have paths which are beginning substrings. You can then get the entire parents path in one SQL query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to crate a simple CMS using drupal, It has 4 pages and
Ok, i have simple scenario: have two pages: login and welcome pages. im using
Should simple JavaBeans that have only simple getters and setters be unit tested?? What
I have a simple webform that will allow unauthenticated users to input their information,
I have a simple 2-column layout with a footer that clears both the right
I am refurbishing a big CMS that I have been working on for quite
I have a large .NET web application. The system has projects for different intentions
I have just started a simple CMS in Rails 2.3. The application will get
I'm trying to write a really simple prototype of a CMS system using ASP.Net
I'm working on a simple custom cms - this is for a school that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.