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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:48:56+00:00 2026-06-08T11:48:56+00:00

I’m creating a Facebook web application which functions in a similar way to a

  • 0

I’m creating a Facebook web application which functions in a similar way to a dating website, by getting users to provide information about themselves and information about their preferences in a matching user.

I am creating the database for this and have the following design in mind:

  • Members Table: Contains the information about the users using their FB ID as the primary key.
  • Preferences Table: Contains the information about the preferences that the user wants.

There are going to be approximately 20 fields which the user can specify a preference in but all of them will be optional. I am unsure about the best way to structure my “preferences” table and I currently have two ideas:

Solution 1: Use a foreign key of the facebook ID and have a new column for each field which can be matched on. A problem which I can see is that there will be a lot of “null” values in the database for fields which a value has not been specified.

  • Do “null” values in a database occupy space or cause any other problems?

Solution 2: Use a foreign key of facebook ID again, but in the next two columns use a key-value pair approach – so one column would contain an ID for a user preference and the other would contain a value for it. For each user preference I would have a record with structure: “user ID” – “preference ID” – “value”.

  • problem with this is that the type of value in the “value” column will depend on the contents of the “preference ID” column

My question:

  • Which approach is better?
  • Is there a standard schema solution to this sort of web application?
  • 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-08T11:48:57+00:00Added an answer on June 8, 2026 at 11:48 am

    As you’ve noticed, either way you are looking at a compromise. Which way you go depends on what your production data is really going to look like.

    Null values in sparse tables do take up a little bit of space, but not very much – as long as your columns use variable length data. Ten null varchars aren’t very long. Ten null ints are just as long as ten non-null ints.

    If you add a third table “PreferableThings” that is keyed by the “preference ID” in your second solution, then what you have is not technically key-value pair or EAV, which most people shun. The difficulty, as you’ve noted, is that preferences with different data types have to be stored in a common encoded form (usually varchar). This solves the issue with sparse tables, but it forces you to create some application logic to decode from the common data type to the proper native data type. You can store the rule for doing this on the “PreferableThings” table.

    Another advantage of the second approach, however, is that you can table-drive the addition of new preference options. With solution 1 you would need a schema change.

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

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a view passing on information from a database: def serve_article(request, id): served_article

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.