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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:21:57+00:00 2026-06-13T19:21:57+00:00

I have a class, let’s call it TableOwner , and one of its fields

  • 0

I have a class, let’s call it TableOwner, and one of its fields is a DataTable with a column for name (which is also the primary key) and a column for amount. So there is one primary key column and a second non-primary column.

In my program, I create a collection of TableOwner instances. The collection is essentially a set: Logically there is no order of TableOwner‘s, it only matters how many of each kind exist. Each one’s DataTable is populated with different values for amount, but they all have the same primary key.

For example, imagine TableOwner is used to store data on bank accounts. Each instance represents one account, then the DataTable might record how much of each currency there is in the account. For every account, the number of dollars, euros or pounds in that account may differ, but for every account, there is data on these same three currencies, even if the amount is 0 (no money in account) or null (perhaps data is missing). So basically I want a 2-D table or matrix, but my class hierarchy impedes me from implementing it as such.

What is a sensible way to deal with all of this? I can think of the following approaches:

1) Make a DataColumn first and then pass it to all new instances of TableOwner to be used for their own DataTable‘s. Downside: If I later decide I want to remove a row from the primary key (eg the user decides “You know what, I don’t care about euros anymore, dump all the data on them and remove the column.”), I must iterate through the whole collection and remove the row from each TableOwner‘s table one by one.

2) Make a single DataTable used by all of the TableOwner instances (perhaps make it a static field). Instead of one amount column, the table will have many columns, such as Amount1, Amount2 and so on. Every TableOwner instance creates its own amount column at initialization and remembers its name for later – now removing a row is an elementary DB operation. Downside: Seems inelegant and “wrong”.

As you can see, both have a downside. Is there a better way?

Apologies if the question is very basic or worded strangely, as I don’t know much about databases.

  • 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-06-13T19:21:58+00:00Added an answer on June 13, 2026 at 7:21 pm

    You should have a table with Columns for Owner, Currency and Amount

    So instead of

     Owner1 20$ £30 €40
    

    You have three records

     Owner | Currency | Amount
     Owner1  $          20
     Owner1  £          30
     Owner1  €          40
    

    (Where the currency symbols represent Currency IDs from a separate Currency table)

    If a person doesn’t have an amount in a particular currency, then there is no record for the combination of person and currency.

    This is part of the process of normalisation

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

Sidebar

Related Questions

I have a class (let's call it Class1), which inherits another class (Class2). What
I have a class(let's call it foo ) which contains 20 members. The class
Ok, I have one class (let's call it: MenuBarClass) that contain multiple Menu and
I have one abstract class -let's say myBase. And I want all the classes
In Visual Studio 2008 (C++) I have a class destructor (Let's call this class
I have created a separate class (let's call it class2.cs for example) and want
I have a non-Activity class (let's call it NonActivity) that needs to post a
I currently have a need for a custom ListViewItem class - let's call it
i have a class let's call it cell, .cms-block .cell{ width:520px; float:left;} .cms-block.wide .cell{width:
I have a class (let's call it myClass ) that implements both __hash__ and

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.