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

  • Home
  • SEARCH
  • 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 6007305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:39:43+00:00 2026-05-23T01:39:43+00:00

I am trying to design a database strcuture for a questionnarie, and then an

  • 0

I am trying to design a database strcuture for a questionnarie, and then an application that can display that questionnarie.

In my database, i have an entity table called Category. Each Category can have multiple subcategories, which each can have multiple subcategories etc. This is a recursive association.

Currently i have designed it as follows:

[Table: Category]
category_id
category_number
category_name
parrent_id

[Table: Question]
question_id
question_number
question_wording
question_category

A concrete example would be:

- Categories

category_id = 1
category_number = 1
category_name = Milk Products
parret_id = null

category_id = 2
category_number = 1.1
category_name = Cheese
parent_id = 1

category_id = 3
category_number = 1.1.1
category_name = Soft
parrent_id = 2

- Questions

question_id = 1
question_number = 1
question_wording = "From 1-5, how much do you like soft cheese?"
category_id = 3

question_id = 2
question_number = 1
question_wording = "How much do you like cheese?"
category_id = 2

How would i loop through the categories and display each category and question like this:

Questionnarie
- Milk products
-- Cheese
-- "How much do you like cheese?"
--- Soft-Cheese
--- "From 1-5, how much do you like soft cheese?"

I am using the entity framework to load my database into c#

Thanks in advance!

  • 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-23T01:39:44+00:00Added an answer on May 23, 2026 at 1:39 am

    You would do this the same as you would do with normal C# code. You can make recursive function calls:

    public IEnumerable<Category> GetSubCategoriesFor(int catId)
    {
        var subs = db.Categories.Where(c => c.ParentId == catId);
    
        foreach (var sub in subs)
        {
            yield return sub;
    
            // Recursive call
            foreach (var subsub in GetSubCategoriesFor(sub.Id))
            {
                yield return subsub;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to design application that will have UI with database in the backend.
I have a legacy database with a pretty evil design that I need to
I am trying to come up with a database design that will be suitable
I have an App that I am trying to design the data model for.
I'm trying to design a database for a sports meeting. I think I've got
I've been trying to design a database schema for a side project but I
I am trying to so something like Database Design for Tagging , except each
I am trying to find the best way to design the database in order
I'm trying to design an application based on the OpenSocial API , and I'm
I'm trying to design a model for a application allowing 2 people to bet

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.