200 likes | 296 Views
Insensitive – Not a Bad Thing for Data. Noreen Redden Information Builders. Why Case Insensitivity Two Worlds. Why ? How? Problem?. Why Case Insensitivity Two Worlds: Selection. SQL SELECT T1. " LN " ,T1. " FN “ ,T1. " PAY " FROM master.dbo.EMPSQL T1
E N D
Insensitive – Not a Bad Thing for Data Noreen Redden Information Builders
Why Case InsensitivityTwo Worlds Why ? How? Problem?
Why Case InsensitivityTwo Worlds: Selection SQL SELECT T1."LN",T1."FN“,T1. "PAY" FROM master.dbo.EMPSQL T1 WHERE (T1. "LN" = 'deFazio‘); DEFAZIO ANTHONY 10,000 deFazio Anthony 10,000 DeFazio Anthony 10,000 TABLE FILE EMPSQL PRINT LN FN PAY WHERE LN EQ 'deFazio' END deFazio Anthony 10,000
Why Case InsensitivityTwo Worlds: Selection – NOT Optimized TABLE FILE EMPSQL PRINT LN FN PAY WHERE UPCASE(15,LN, 'A15‘) EQ ‘DEFAZIO' END DEFAZIO ANTHONY 10,000 deFazio Anthony 10,000 DeFazio Anthony 10,000 SQL SELECT T1."LN",T1."FN",T1.CDEPT,T1."CDIV",T1.PAY FROM master.dbo.EMPSQL T1
Why Case InsensitivityTwo Worlds: Selection TABLE FILE EMPSQL SUM PAY BY LN BY FN WHERE LN EQ 'deFazio' END SQL SELECT T1."LN",T1."FN", SUM(T1."PAY“) FROM master.dbo.EMPSQL T1 WHERE (T1. "LN" = 'deFazio‘) GROUP BY T1."LN",T1."FN“ ORDER BY T1."LN",T1."FN"; DEFAZIO ANTHONY 30,000
Why Case InsensitivityTwo Worlds: Sorting TABLE FILE EMPSQL PRINT FN PAY BY LN WHERE UPCASE(15,LN, 'A15‘) EQ ‘DEFAZIO' OR ‘FAZIO' END DEFAZIO ANTHONY 10,000 DeFazio Anthony 10,000 FAZIO Anthony 9,000 Fazio Anthony 11,000 deFazio Anthony 10,000 Fazio Anthony 10,000
COLLATION Why ? How? Problem? Collation is defined as a set of rules that apply to the ordering and matching of all language elements that involve comparison of two values
Collation is SettableRelease 7.7 SET COLLATION = BINARY SRV_CI SRV_CS CODEPAGE • BINARY Bases collation sequence on binary values • SRV_CI Bases collation sequence on LANGUAGE • Setting, and is INSENSITIVE • SRV_CS Bases collation sequence on LANGUAGE • Setting and is SENSITIVE • CODEPAGE Bases collation on the code page in effect, and is • SENSITIVE.
Collation is SettableRelease 7.7 A ? a A ? b 1 ? A
Insensitive ServerSelection TABLE FILE EMPSQL PRINT LN FN PAY WHERE LN EQ 'deFazio' END SQL SELECT T1."LN",T1."FN“,T1. "PAY" FROM master.dbo.EMPSQL T1 WHERE (T1. "LN" = 'deFazio‘); DEFAZIO ANTHONY 10,000 deFazio Anthony 10,000 DeFazio Anthony 10,000
Insensitive ServerSorting TABLE FILE EMPSQL PRINT LN FN PAY BY LN WHERE LN EQ ‘DeFazio' OR ‘Fazio' END DEFAZIO DEFAZIO ANTHONY 10,000 DeFazio Anthony 10,000 deFazio Anthony 10,000 Fazio Fazio Anthony 11,000 FAZIO Anthony 9,000 Fazio Anthony 10,000
Selection Why ? How? Problem?
Insensitive ServerTemporary Files - FIXRETRIEVE TABLE FILE EMPSQL PRINT PAY BY LN BY FN WHERE LN EQ ‘defazio’ OR ‘fazio’ OR ‘deanna’ ON TABLE HOLD AS TEMP FORMAT ALPHA END Deanna Maria 25,000 DEFAZIO ANTHONY 10,000 DEFAZIO Anthony 10,000 DEFAZIO Anthony 10,000 Fazio Anthony 11,000 Fazio Anthony 9,000 Fazio Anthony 10,000
Insensitive ServerTemporary Files TABLE FILE TEMP PRINT PAY BY LN BY FN WHERE LN EQ ‘defazio’ END FIXRETRIEVE Would STOP here. Deanna Maria 25,000 DEFAZIO ANTHONY 10,000 DEFAZIO Anthony 10,000 DEFAZIO Anthony 10,000 Fazio Anthony 11,000 Fazio Anthony 9,000 Fazio Anthony 10,000 If Server is set Case INSENSITIVE WHERE test is on an alpha “key” FIXRETRIEVE is set OFF
Insensitive ServerJOIN TABLE FILE EMPSQL PRINT PAY BY LN BY FN WHERE LN EQ ‘defazio’ OR ‘fazio’ OR ‘deanna’ ON TABLE HOLD AS TEMP1 FORMAT ALPHA END Deanna Maria 25,000 DEFAZIO ANTHONY 10,000 DEFAZIO Anthony 10,000 DEFAZIO Anthony 10,000 Fazio Anthony 11,000 Fazio Anthony 9,000 Fazio Anthony 10,000
Insensitive ServerJOIN EMP2 file created in prior release (Case Sensitive) TABLE FILE EMP2 PRINT * END deanna Maria 25,000 fazio Anthony 11,000 samuels Joseph 15,000 DEFAZIO ANTHONY 10,000
Insensitive Server JOIN LN IN EMP2 TO MULTIPLE LN IN TEMP AS AJ TABLE FILE EMP2 PRINT * END JOIN to a Sequential File: Both files Must be in ascending order on COMMON KEY Correct sequence is determined by setting of collation. TABLE FILE EMP2 PRINT * BY LN ON TABLE HOLD AS EMP3 FORMAT FOCUS INDEX LN END JOIN LN IN EMP3 TO MULTIPLE LN IN TEMP AS AJ TABLE FILE EMP3 PRINT * END
Insensitive Server • JOIN to FOCUS/FIX files to be reliable must • Use numeric keys • Use Keys that follow a specific pattern: Unnn • Have been created using the same collation sequence. • JOIN to (or selection from) case sensitive files to be reliable must • Use numeric keys • Use Keys that follow a specific pattern: Unnn • Avoid indexes for selection.
The Sensitive WorldCome in and Stay Set it And Forget it
The Sensitive WorldCome in and Stay Why ? How? Problem? What’s Next ?