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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:06:33+00:00 2026-06-11T21:06:33+00:00

I have a db model similar to this: Foreign key for multiple tables .

  • 0

I have a db model similar to this: Foreign key for multiple tables.

I have account table. An account may be of type venue or band. I decided to make a composite key in account table: id_account | type – together they’d make up a PK (type may be venue or band or their numeric equivalents)

I know how I’d e.g. select all venues with data from account table as well: SELECT account.*, venue.* FROM venue INNER JOIN account ON (venue.id=account.id AND type=venue).

Now, I have an administration panel in which user has his account (which is one of those type – venue or band). When he logs, the panel is different for venue accounts and for bands accounts. Do I need one query to check the type of account (let’s say it’s venue) and then another query to the venue table to grab his data? Otherwise – can I do something similar to:

SELECT ... FROM IF(type=venue, venue, band)
  • 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-11T21:06:34+00:00Added an answer on June 11, 2026 at 9:06 pm

    There are several approaches to this. It’s probably not too expensive to do the two queries but if you want you could join the ‘account’ query to both ‘band’ and ‘venue’ tables (by some unique ID for either) then take the appropriate column from the result depending on the ‘account type’ column in the result.

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

Sidebar

Related Questions

I have a model similar to this: public class myModel { public ClassA ObjectA
I have a class Similar to this public class Model { public TimeSpan Time1
I have a table which needs 2 fields. One will be a foreign key,
I have a model with a ManyToManyField similar to this one (the model Word
I have some Django models with a structure similar to this: class Grandparent(models.Model): name
I have a model similar to this one: class MyModel(models.Model): name = models.CharField(max_length =
I have a Core Data model similar to this: Company Entity companyName attribute (string)
I have a model similar to the following: class Review(models.Model): venue = models.ForeignKey(Venue, db_index=True)
I have an app with a similar structure as this snippet class Blog(models.Model): name
I have a question similar to this thread : [throwing-exceptions-from-model-view-controller-in-a-zend-framework-application][1] I have a standard

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.