Author |
Topic  |
Deleted
deleted
    
4116 Posts |
Posted - 23 October 2002 : 02:56:18
|
quote: Originally posted by bjlt
will you use a country table? If so, how will you use it?
No. I don't see any reason for loosing some performance in joins...
|
Stop the WAR! |
 |
|
Azaniah
Senior Member
   
United Kingdom
1004 Posts |
Posted - 23 October 2002 : 04:44:06
|
ooo this reminds me of a secret MOD I was (am) working on...
LOL...Now you are all going to be wondering what it is  |
Eagles fly!, but weasels don't get sucked into jet engines. |
 |
|
bjlt
Senior Member
   
1144 Posts |
Posted - 23 October 2002 : 05:04:57
|
quote: Originally posted by bozden
No. I don't see any reason for loosing some performance in joins...
Then how will you handle the internatinalization? Is it possible to avoid joins by matching country names and ID in asp codes? |
 |
|
Deleted
deleted
    
4116 Posts |
Posted - 23 October 2002 : 05:59:21
|
Country names are not translated. We only give the opportunity to substitute the default country name.
Also we don't use countries as base, nor the languages. The LocaleID concept is the best developed methodology in this area. |
Stop the WAR! |
Edited by - Deleted on 23 October 2002 06:02:00 |
 |
|
bjlt
Senior Member
   
1144 Posts |
Posted - 23 October 2002 : 06:32:25
|
I agree LocaleID is the best.
I plan to store the country_id, country_names of supported languages in a table, but output it as files for inclusion and matching names with ids, while store the id only in the member table. Hopefully I can get a bit performance gain when searching members by country names.
BTW, how do you match languages with LocaleIDs? |
 |
|
bjlt
Senior Member
   
1144 Posts |
Posted - 23 October 2002 : 06:47:11
|
Well, I need this as I run an international community where people would search members by country often.
e.g.
COUNTRY_LIST COUNTRY_ID, COUNTRYNAME_EN, COUNTRYNAME_GB (note: How many translations of country names is not important here. I may only support one or two languages, without much relationship with the localID, maybe for my own site "if not GB then EN") 1. Afghanistan 2. Albania .....
Then I output the table as files, maybe: country_selection_en.asp
<select name="Country" size="1"> <option value=""></option> <option value="">None</option> <option value="1">Afghanistan</option> <option value="2">Albania</option> ......
country_selection_multi_en.asp
<select multiple name="Country" size="4" > <option value=""></option> <option value="">None</option> <option value="1">Afghanistan</option> <option value="2">Albania</option> ......
Maybe also store ids and country names in an array or application
by doing so, we can change the country field to number, which should be easier to search and change. |
Edited by - bjlt on 23 October 2002 06:53:18 |
 |
|
bjlt
Senior Member
   
1144 Posts |
Posted - 23 October 2002 : 06:55:16
|
actually for the end snitz user, they don't need to use such a country table, it's for maintainace only. |
Edited by - bjlt on 23 October 2002 06:56:00 |
 |
|
seven
Senior Member
   
USA
1037 Posts |
Posted - 23 October 2002 : 08:55:19
|
So, In Summary: The DEV team is looking into country list naming conventions for v4?
|
|
 |
|
bjlt
Senior Member
   
1144 Posts |
Posted - 23 October 2002 : 10:44:48
|
This is for people who want to store country_id instead of country_name in the members table, by using these functions you don't need to join the country table with the one for the member.
need new table: COUNTRY_LIST: COUNTRY_ID COUNTRY_NAME change M_COUNTRY to int or use new field M_COUNTRY_ID
SQLVal is a function I take from other application, which changes everthing to a value of number FVal is a function to convert everything to a value of numer. you don't need to use them.
strApplicationPrefix is a variable I use to replace strUniqueID or strCookieURL in some places, change it to the one you use for applications variables
<%
Function GetMemberCountry(fMemberID)
Dim strSql, rsChk, iCountryID
'todo: new field M_COUNTRY_ID in MEMBERS, which is default as 0
strSql = "SELECT M_COUNTRY_ID "
strSql = " FROM " & strMemberTablePrefix & "MEMBERS me"
strSql = " WHERE me.MEMBER_ID = " & SQLVal(fMemberID)
set rsChk = Server.CreateObject("ADODB.Recordset")
rsChk.open strSql, my_Conn
if rsChk.bof or rsChk.eof then
GetMemberCountry = ""
else
iCountryID = FVal(rsChk("M_COUNTRY_ID"))
GetMemberCountry = GetCountryName(iCountryID)
end if
rsChk.close
set rsChk = nothing
End Function
Function GetCountryName(fCountryID)
'this doesn't handle more than one set of country names yet.
Dim txtCountryListID, txtCountryListName, CountryListID, CountryListName
Dim strSql, iCountryListCount, allCountryListData
Dim fld_CountryID, fld_CountryName, i
Dim iCountryPosition, aryCountryListID, aryCountryListName
if trim(Application(strApplicationPrefix & "STRCOUNTRYLISTID")) = "" or trim(Application(strApplicationPrefix & "STRCOUNTRYLISTNAME")) = "" then
txtCountryListID = ""
txtCountryListName = ""
'## Forum_SQL - Get Country List from DB
strSql = "SELECT COUNTRY_ID, COUNTRY_NAME "
strSql = strSql & " FROM COUNTRY_LIST "
set rsCountryList = Server.CreateObject("ADODB.Recordset")
rsCountryList.open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
if rsCountryList.EOF then
iCountryListCount = 0
else
allCountryListData = rsCountryList.GetRows(adGetRowsRest)
iCountryListCount = UBound(allCountryListData,2)
end if
rsCountryList.close
set rsCountryList = nothing
if iCountryListCount <> 0 then
fld_CountryID = 0
fld_CountryName = 1
for i = 0 to iCountryListCount
CountryListID = allCountryListData(fld_CountryID,i)
CountryListName = allCountryListData(fld_CountryName,i)
if txtCountryListName = "" then
txtCountryListID = CountryListID
txtCountryListName = CountryListName
else
txtCountryListID = txtCountryListID & "," & CountryListID
txtCountryListName = txtCountryListName & "," & CountryListName
end if
next
end if
Application.Lock
Application(strApplicationPrefix & "STRCOUNTRYLISTID") = txtCountryListID
Application(strApplicationPrefix & "STRCOUNTRYLISTNAME") = txtCountryListName
Application.UnLock
end if
txtCountryListID = Application(strApplicationPrefix & "STRCOUNTRYLISTID")
txtCountryListName = Application(strApplicationPrefix & "STRCOUNTRYLISTNAME")
aryCountryListID = split(txtCountryListID, ",")
aryCountryListName = split(txtCountryListName, ",")
iCountryPosition = PositionInArray(aryCountryListID, Fval(fCountryID), vbTextCompare)
GetCountryName = aryCountryListName(iCountryPosition)
End Function
Function PositionInArray(aMyArray, strLookingFor, compare)
'Return the position strLookingFor is found in aMyArray... if
'strLookingFor is not found, -1 is returned.
Dim iUpper, iLoop
iUpper = UBound(aMyArray)
For iLoop = LBound(aMyArray) to iUpper
If compare = vbTextCompare then
If CStr(UCase(aMyArray(iLoop))) = CStr(UCase(strLookingFor)) then
PositionInArray = iLoop
Exit Function
End If
Else
If CStr(aMyArray(iLoop)) = CStr(strLookingFor) then
PositionInArray = iLoop
Exit Function
End If
End If
Next
'Didn't find the element in the array...
PositionInArray = -1
End Function
%>
|
Edited by - bjlt on 23 October 2002 10:58:51 |
 |
|
Deleted
deleted
    
4116 Posts |
Posted - 23 October 2002 : 11:33:00
|
Yeah, but that would mean an extra database call for all posts in topic.asp page. Currently they are taken directly from the database. Your code would mean 20 more database queries in a 20 reply topic.asp page... I also see a lot of Application object access, which is expensive (12 times slower than a simple variable access)
What I'm saying was there is no valuable gain for that cost.
|
Stop the WAR! |
Edited by - Deleted on 25 October 2002 15:46:09 |
 |
|
bjlt
Senior Member
   
1144 Posts |
Posted - 23 October 2002 : 11:46:37
|
well, please help me to clarify on this:
I didn't now that application object access is that slower than a simple variable access, that part of code is a resemble of chkBadWords, if it's true, why don't that function use variables£¿
What I though was, the Application values will be stored in memory and not changed, then no need to call the db for the country names. when retrive member table info, we get country_id instead, and use GetCountryName(fCountryID) to get the country name, and then you can store it in a variable. yes it's an extra process of asp, but no extra db calls at all, then it comes to the first question, is it slow or not?
generally Function GetMemberCountry(fMemberID) is only used when there's no existing country_id for that member, try to avoid using it as it calles the db.
what I get is when searching by country, it now searches numbers instead of strings, and a bit space saving on the db.
frankly speaking I don't know if it's worth doing or not.  
|
Edited by - bjlt on 23 October 2002 11:48:56 |
 |
|
bjlt
Senior Member
   
1144 Posts |
Posted - 23 October 2002 : 12:04:56
|
well, just remember the reason why I tried to use a country table and country_id, I need to categorize people into different areas, east asia, north american etc, haven't decided how to do it though. |
 |
|
bjlt
Senior Member
   
1144 Posts |
|
Reinsnitz
Snitz Forums Admin
    
USA
3545 Posts |
Posted - 26 October 2002 : 10:33:31
|
The answer to this all is realy quite simple. We only use the ISO list. If it's not in there we most likely won't include it. It is the International standard for country lists. |
Reinsnitz (Mike) |
 |
|
seven
Senior Member
   
USA
1037 Posts |
Posted - 26 October 2002 : 16:44:30
|
In that case, USA should become "United States", correct?
quote: Originally posted by reinsnitz
The answer to this all is realy quite simple. We only use the ISO list. If it's not in there we most likely won't include it. It is the International standard for country lists.
|
|
 |
|
Topic  |
|