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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:52:47+00:00 2026-06-13T22:52:47+00:00

I have an application that displays tabular information and allows the user to enter

  • 0

I have an application that displays tabular information and allows the user to enter and edit it. I have been working on the database design for this and have come across the following problem.

I want to avoid creating an MSSQL table for each table in the application, so I’ve been trying to represent all of the tables together, in two tables.

I have defined a MyAppTable table which has Id INTEGER primary key and a Name CHARACTER VARYING(255) columns.

From there, I have defined a MyAppColumn table which foreign keys against the MyAppTable.Id column and also has a Position INTEGER column to indicate its position in the rendered table.

Finally, I have defined a MyAppRow table which foreign keys against the MyAppColumn.Id column and has a Data BINARY(32) column. It’s a table of small files, so this data type is fitting.

The actual problem is that I cannot guarantee that the MyAppColumn.Position column will be unique for each MyAppTable.

An example of a normal situation:

  • MyAppTable with Id 0
  • MyAppColumn with Id 0, TableId 0, Position 0
  • MyAppColumn with Id 1, TableId 0, Position 1
  • MyAppRow with ColumnId 0, Data [something]
  • MyAppRow with ColumnId 1, Data [something]
  • MyAppTable with Id 1
  • MyAppColumn with Id 2, TableId 1, Position 0
  • MyAppRow with ColumnId 2, Data [something]

An example of a situation I want to make impossible in the database:

  • MyAppTable with Id 0
  • MyAppColumn with Id 0, TableId 0, Position 0
  • MyAppColumn with Id 1, TableId 0, Position 0

As you can see, I want some way of constraining a pair of columns. The two columns TableId and Position should be UNIQUE but if that were done independently, it would mean two tables could never have columns both at a Position of 0.

How can I accomplish this in Microsoft SQL Server 2012?

  • 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-13T22:52:48+00:00Added an answer on June 13, 2026 at 10:52 pm

    The solution to your problem is to not encode metadata in tables but to create actual tables, even if it’s inconvenient or a lot of work.

    Some stuff that will bite you in the rear very soon:

    • No relationships can be modeled
    • No way to index
    • No input validation (is that a date or an int or an image?)
    • No way to get actual accurate statistics
    • Every single query that you write will be a nightmare

    Save yourself a lot of time and effort in the future and just make actual tables now in the design phase. This type of meta-data “god table” has been tried repeatedly and never works.

    That being said, if you are representing a very limited set of data (like you say, for files only), I would consider a coordinate system.

    Keep your MyAppTable as is.

    Create a MyAppFile table with fields:

    • FileId (int identity)
    • MyAppTableId (FK)
    • Data (varbinary)
    • XPos (int)
    • YPos (int)

    With a unique constraint on (MyAppTableId, Xpos, Ypos).

    This more accurately represents what you are trying to store, will be easier to maintain, and allows you to enforce integrity.

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

Sidebar

Related Questions

I have an application that displays a dialog when the user needs to enter
I have a portlet. Inside of this portlet I have Flex application that displays
I have an existing application that displays the ship track information using jmonkeyengine as
I have an access application that displays data from our database and does some
I have an application that displays user data in a sorted list. The list
I have an application that displays contacts from the contact book. This isnt hard:
I have made an application that displays a lot of questions from my database.
I have Java Desktop application that displays some information in a JTable that contains
I have a PHP application that displays a list of options to a user.
I have Java Desktop application that displays some information in a JTable that may

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.