Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which is the most effective structure for tables/indexes????

Status
Not open for further replies.

Tore

Technical User
May 18, 2001
29
NO
Hi.

Have one table with FIXED row length.
Table name: "thetable".
Field 1: MemID (mediumint). (relates to another table members)
Field 2: TheID (smallint).
Primary key: MemID, TheID.
Lots of fields. Fixed table length.

I want to make it possible for users to search for records in this table related to one or more keywords.

Since I want thetable to be as small as possible I want to store the releated keywords in another table:

Solution A:
Either in a table called thekey with these fields, keys and indexes:
Field 1: MemID.
Field 2: TheID.
Field 3: Keywords (Varchar (255)).
Primary key: MemID, TheID.
Index on Keywords field as FULLTEXT index.

Solution B:
Or in a table called thekey with these fields, keys and indexes:
Field 1: MemID.
Field 2: TheID.
Field 3: Keyword (varchar (30)).
Primary key: MemID, TheID, Keyword.
Index on Keyword.

QUESTION 1:

Which of the two solutions will make the fastest select queries if I search like this:

Solution A: Searches would be done like this:
select TheID from thekey where match (Keywords) against ('theword');


Solution B: Searches would be done like this:

select TheID from thekey where Keyword like 'theword%';
or
select TheID from thekey where Keyword like 'theword';



Consider houndreds of thousands of records in table "thetable".

QUESTION 2:
Which of the two solutions will use less diskspace?


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top