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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:16:58+00:00 2026-05-18T08:16:58+00:00

I have a table of people quite standard stuff e.g. : CREATE TABLE [Contact](

  • 0

I have a table of people quite standard stuff e.g. :

CREATE TABLE [Contact](
[ContactID] [bigint] IDENTITY(1,1) NOT NULL,
[ContactType] [nvarchar](50) NULL,
[Forename] [nvarchar](60) NULL,
[Surname] [nvarchar](60) NULL,
[Company] [nvarchar](60) NULL
}

Example Data : 
01, "Student", "Bob", "Smith", Blank
02, "Staff", "Robert", "Smithe", "Roberts And Sons"
Etc

This table contains all the fields common to all contacts. However i have some “types” of contact that may or may not have a field which is specic only to that type of contact. For example if the record has “ContactType=’student'” i want to store an extra field called “studentid”. There are many different types of contact each with slightly different field requirements. To add to this situation at somepoint in the future each contact type might have extra fields added.

If i add each field to the contacts table i would end up with lots of fields which are not required for 99% of the records. So i was planning on creating a second table like this:

CREATE TABLE [ContactMetaData](
 [ContactID] [bigint] NOT NULL,
 [PropName] [nvarchar](200) NOT NULL,
 [PropData] [nvarchar](200) NULL
)

Example Data:
01, "StudentID", "0123456"
01, "CourseName", "IT"
01, "Average", "10"
02, "Ranking", "22"
02, "ProductTypes", "IT Equipment"
ETC

For each extra field i just add a record into this table with the name and value for the field. I can use code to pull this information up etc.

My question is

Is this the best approach as i’m stumped of another way other than a huge table with every single field. Given this approach is it possible to do complex querys across many of the property fields and if so how? e.g. how would i list all the students on the “IT” course with an “Average” of 10 whos “forename” starts with “D”?

  • 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-18T08:16:58+00:00Added an answer on May 18, 2026 at 8:16 am

    Yes, if you really have many many fields that are not used, go for this approach (called an EAV data structure). You can do all queries on this structure that you can with a normal model, just use appropriate joins to pivot them.

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

Sidebar

Related Questions

I have a table that has two columns: CommunityID PersonID And A People table
The best way of describing this is I have a table of people with
I have a table that shows the relationships between people a bit like this.
I have a table in my DB with a list of people. I need
I've got a table that people have been inserting into getting the primary key
We have a table value function that returns a list of people you may
In my MySQL table Winners , I have a list of people who have
I have a table people Name Id Age Sex Country Ankit ankitgautam24 17 M
Since I'm sure many people have different standard, I've made this post a community
I have a table called People with a columns of datatype xml called properties

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.