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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:34:04+00:00 2026-05-11T09:34:04+00:00

I have the following schema in the database: BillingReferences (ReferencingType tinyint , ReferencingId tinyint

  • 0

I have the following schema in the database:

  • BillingReferences (ReferencingType tinyint, ReferencingId tinyint, ReferencedType tinyint, ReferencedId tinyint, IsActive bit) – where all fields (except IsActive) are part of a Unique Index.
  • BillingType (BillingTypeId tinyint, Name varchar(50))

ReferencingType and ReferencedType is a foreign key of BillingTypes. BillingTypes contains the following rows:

BillingTypeId | Name

1 | Labels

2 | Countries

3 | PaymentProviders

4 | PaymentOptions

5 | Banks

ReferecingId and ReferencedId represent the Id of one of the following entities (depends on the Referenced/Referencing Type):

  • Banks (BankId tinyint, Name varchar(50))
  • Countries (CountryId tinyint, Name varchar(50))
  • Labels (LabelId tinyint, Name varchar(50))
  • PaymentProviders (PaymentProviderId tinyint, Name varchar(50))
  • PaymentOptions (PaymentOptionId tinyint, Name varchar(50))

In the future each entity will have some more different columns added but for now this is the schema for simplicity.

There’s a connection of (1-) between every entity (except countries) to countries. Labels have a connection of (1-) to Banks, PaymentProviders and PaymentOptions. And PaymentProviders have a connection of (1-*) to PaymentProviders

So for example if I want to connect a bank with BankId 201 to a country with CountryId 3003 I will have a record in BillingReferences that will look like that: ReferencingType = 5 ReferencingId = 201 ReferencedType = 2 ReferencedId = 3003 IsActive = 1

We didn’t make a connection/reference table for each type of connection because of extendability consideration – If we want to add another entity all we have to do is add its table and add records for it in BillingReferences and BillingType.

The problem is that I can’t configure a conditional foreign key between BillingReferences and each of the entities and I can’t seem to configure/map it with EntityFramework either…

I was unable to find any tutorial or example that uses this type of implementation. Am I bound to create a reference table for each connection, or is there a way to configure this with EntityFramework?

Thanks for the help 🙂

  • 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. 2026-05-11T09:34:05+00:00Added an answer on May 11, 2026 at 9:34 am

    AFAIK, there’s isn’t a way to do this.

    I’d go with creating a seperate table for each type, unless you really have a good reason not to. The consideration you mention isn’t a good one, IMHO.

    Having more tables DOES allow you to put foreign key constraints on your keys, and it translates nicely into the EF. It also helps performance: your big ass reference table with one million rows will take more time to query than more smaller tables (unless you ALWAYS want all references for a type).

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

Sidebar

Ask A Question

Stats

  • Questions 101k
  • Answers 101k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's a bit difficult to determine how involved such an… May 11, 2026 at 8:02 pm
  • Editorial Team
    Editorial Team added an answer Try wrapping your call like this; Display.getDefault().asyncExec(new Runnable() { public… May 11, 2026 at 8:02 pm
  • Editorial Team
    Editorial Team added an answer I believe what you're looking for is the scrollIntoView method:… May 11, 2026 at 8:02 pm

Related Questions

I have a Mail model with the following schema: t.string mail t.integer country t.boolean
I have an application built upon ASP.NET 3.5 and PostgreSQL 8.3. My database has
I'm using Linq to entities applying a Table per Type approach. This has been
I'm trying to generate a sales reports which lists each product + total sales

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.