MYSQL
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists MYSQL

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old July 6th, 2008, 06:01 PM
Waynn Lue
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Schema Design

I have two tables, Applications and Settings. Here are the two schemas:

mysqldesc Applications;

| Field | Type | Null | Key | Default |
Extra |

| ApplicationId | bigint(20) unsigned | | PRI | NULL |
auto_increment |
| ApplicationName | varchar(200) | YES | | NULL
| |


mysqldesc Settings;

| Field | Type | Null | Key | Default | Extra |

| ApplicationId | bigint(20) unsigned | | PRI | 0 | |
| SettingId | int(10) unsigned | | PRI | 0 | |
| SettingValue | text | YES | | NULL | |


Settings is just a multi map, where I'll have things like (1, 1, "true"),
(1, 2, "short text"), (1, 3, "145"), etc. Essentially each Application has
multiple rows in Settings.

There are values in Settings that I want to index, for example I want to
find all ApplicationIds where SettingId = 34 and SettingValue = "149951".
Here are the two methods I'm considering.

1. Add an index on (SettingId, SettingValue). It allows me to look for any
arbitrary combination of SettingId, SettingValue, and it also gives me
flexibility in that any thing I add to the table, it'll automatically be
indexed. Problem is that there are combinations that I'll never care about,
so I'm wasting space and INSERT time.
2. Pull the values that I'm interested in out into Applications, and add it
as a column that that table with a secondary index. I'll have to update
both Applications and Settings in a transaction, and make sure they're kept
consistent. This is more efficient, but every time I want to index
something new, I'll have to either take down Applications and add a new
column, or I'll have to create another table and INNER JIN it to
Applications.

Does anyone have experience building out a system that's similar? Am I
getting all the pros and cons? Also, is a VARCHAR better than a text field
in terms of indexing, or even in terms of performance?

Thanks for any input,
Waynn

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists MYSQL > Schema Design


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway