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 786235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:00:32+00:00 2026-05-14T21:00:32+00:00

I have very little experience designing databases, and now I want to create a

  • 0

I have very little experience designing databases, and now I want to create a very simple database that does the same thing I have previously had in xml. Here’s the xml:

<services>
  <service type="writing">
    <small>125</small>
    <medium>100</medium>
    <large>60</large>
    <xlarge>30</xlarge>
  </service>
  <service type="analysis">
    <small>56</small>
    <medium>104</medium>
    <large>200</large>
    <xlarge>250</xlarge>
  </service>
</services>

Now, I wanted to create the same thing in a SQL database, and started doing this ( hope this formats ok, but you’ll get the gist, four columns and two rows):

> ServiceType Small Medium Large
> 
> Writing       125    100    60
> 
> Analysis       56    104   200

This didn’t work too well, since I then wanted to use LINQ to select, say, the Large value for Writing (60). But I couldn’t use LINQ for this (as far as I know) and use a variable for the size (see parameters in the method below). I could only do that if I had a column like “Size” where Small, Medium, and Large would be the values. But that doesn’t feel right either, because then I would get several rows with ServiceType = Writing (3 in this case, one for each size), and the same for Analysis. And if I were to add more servicetypes I would have to do the same. Simply repetitive… Is there any smart way to do this using relationships or something?

Using the second design above (although not good), I could use the following LINQ to select a value with parameters sent to the method:

protected int GetHourRateDB(string serviceType, Size size)
{
  CalculatorLinqDataContext context = new CalculatorLinqDataContext();
  var data = (from calculatorData in context.CalculatorDatas
        where calculatorData.Service == serviceType && calculatorData.Size == size.ToString()
        select calculatorData).Single();
  return data.Hours;
}

But if there is another better design, could you please also describe how to do the same selection using LINQ with that design?

Please keep in mind that I am a rookie at database design, so please be as explicit and pedagogical as possible 🙂

Thanks!

Anders

  • 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-14T21:00:33+00:00Added an answer on May 14, 2026 at 9:00 pm

    You can use your first method and do something like this:

    protected int GetHourRateDB(string serviceType, Size size)
    {
        using (CalculatorLinqDataContext context = new CalculatorLinqDataContext())
        {
            var data =
                (from calculatorData in context.CalculatorDatas
                where calculatorData.Service == serviceType
                select calculatorData).Single();
    
            switch (size) {
                case Small:
                    return data.Small;
                case Medium:
                    return data.Medium;
                case Large:
                    return data.Large;
                default:
                    // Error handling
             }
         }
    }
    

    Your second method would also work, but if you know that there will always be exactly three sizes for all items, and that they will always be called Small, Medium and Large, then by using the first methods you can hardcode that into the schema and get the database to enforce it for you.

    You might also want to consider if it would be better to use an auto-incrementing primary key instead of using the service name as the primary key. Names have an unfortunate problem that they often change for reasons outside of your control (fix typos, marketing, translations, etc.). You might want to avoid having to recompile your program every time a name changes.

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

Sidebar

Related Questions

I have a strong database background but very little practical experience with ms sql
I have very little experience of submitting iPhone Apps and even that was on
I'm debugging a macro and have very little experience with them, what does the
I have very little experience building software for Windows, and zero experience using the
I have very little experience with ASP.NET and I am doing some self-training before
I have very little experience working with sockets and multithreaded programming so to learn
I have very little experience using Sharepoint but a good amount using Visual Studio
Warning: I have very little JavsScript experience. In my past programming experience, I usually
I have 0 experience with python, very little with regex and I'm trying to
I have very little experience with setting up a website from scratch in a

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.