2

Let's take for example a dating site with 100.000 users. Each users has about 30 attributes like hair color, smoking, age, city, gender, ...Some attributes are bool, some int and some var or text.

About 20 of those attributes are searchable and half of users don't fill data. All values are displayed on user profile page.

I was thinking about the following options:

  1. Split data into 4 tables. Table 1 is used for data that is searched mostly, table 2 for attributes that are mostly unfilled, table 3 for large data like about me, and for rest of table 4.
  2. Separate table for most attributes, so each attribute have own table.
  3. Using EAV model.

I think that the first option would be the best. Or is there any other better way?

mellamokb
  • 56,094
  • 12
  • 110
  • 136
user1324762
  • 765
  • 4
  • 7
  • 24
  • Sounds to me like you're over-thinking it. 100K records is not a lot, and your 30 attributes probably add up to an average of a few hundred bytes for each row. What database will you be using? –  Apr 19 '12 at 21:49
  • Mysql database. I know it is not a lot, but I want to make proper design for potential growth. – user1324762 Apr 20 '12 at 06:55

1 Answers1

0

Assuming you won't have much need for adding new attributes, you're probably best-off just placing everything in one big table. DBMSes are typically fairly efficient in storing NULLs. Indexing NULLs should also be reasonable, some DBMSes don't even include NULLs in indexes (Oracle).

Don't be afraid of BLOBs either - they will tend to "stretch" the rows (if portion of BLOB is placed in-line in the row, which can typically be controlled in DBMS-specific ways), lowering your "data clustering", but this should not be too important for your purposes.

In any case, measure on representative amounts of data before deciding that the most natural solution is not performant enough.

Branko Dimitrijevic
  • 50,809
  • 10
  • 93
  • 167