SQLã¯æãé«ç´è¨èªï¼
ãSQLã¯ãç¾å¨ãæ®åãã¦ããè¨èªã®ä¸ã§æãé«ç´ãªè¨èªã§ããè¨èªã¯é«ç´ã«ãªãã°ãªãã»ã©äººéã«è¿ã¥ãã·ã³ãã«ã«ãããããã¨ãå®ç¾ã§ããåé¢ãå®è¡é度ã¯é ããªããã§ãããã¨ãéããã¾ãã
ãæãä½ç´ãªãã·ã³èªã¨âã®ã¢ã»ã³ããªè¨èªã§ããã°ãã³ã³ãã¥ã¼ã¿ã§ã§ãããã¨ã¯ä½ã§ãã§ãã¾ãããããé«ç´è¨èªã®Javaã«ãªãã°ãJava VMããªããã°ãæä¸ãã«ãªããJava VMã§å¦çå¯è½ãªãã¨ããJavaã§ã¯ã§ãã¾ãããã¹ã¯ãªããè¨èªã¯ã¤ã³ã¿ã¼ããªã¿ããªããã°åããªãããã¡ãããæ´ã«é«ç´ãªè¨èªã®SQLã¯ãDBã¨ã³ã¸ã³ããªããã°ä½ãã§ãã¾ããããã§ãããã¨ã¯DBå ã®å¦çã«éããã¦ãã¾ãã¾ãã
ãè¨èªã¯ãä½ç´ãªã»ã©ã§ãããã¨ãå¤ããé«ç´ã»ã©ç¹å®ã®ãã¨ããã§ããªããªãããã§ãã
ãä¸æ¹ã§ãä½ç´ãªè¨èªã»ã©ãæåå®è¦ã«ãããããæ¡ä»¶ãæ示ããªãã¨ã³ã³ãã¥ã¼ã¿ã¯åããªããªããé«ç´ãªè¨èªã»ã©ã¢ãã¦ããªå½ä»¤ã§ãæãã çµæãå¾ããã¾ãã
ãã¤ã¾ããçè«å¤ã¨ãã¦ã¯ï¼ãã®ãã®ã®ã¹ãã«å·®ããªããã°ï¼é«ç´è¨èªã»ã©å·¥æ°ãæãããªãåé¢ãããã©ã¼ãã³ã¹ã¯é ããªããé«ç´è¨èªã»ã©ããã ãã§ã§ãããã¨ã¯éããã¦ãã¾ãã
ããã¬ã¼ããªãã®é¢ä¿ã¯ã
ããããå·¥æ° ï¼âï¼ ããã©ã¼ãã³ã¹ã»ä½ç´ï¼ãã·ã³ã«è¿ãï¼å¦çã®å®ç¾
ãã¨ãªãã¾ããä¾ãã°ãOSã®ã«ã¼ãã«é¨åãããã«è¿ãé¨åã¯ãä½ç´è¨èªã®ã¢ã»ã³ããªè¨èªãæ¡ç¨ããããã¨ãå¤ããªãã¾ãããã·ã³ã«è¿ãå¦çã¨ãã¦ãããã¤ã¹ãã©ã¤ãã¼ãæã¯ã¢ã»ã³ããªè¨èªãæ¡ç¨ããã¦ãã¾ãããããã·ã³èªä½ãéããªã£ããã¨ã«ãã£ã¦ãããã©ã¼ãã³ã¹ï¼ãã¡ã¤ã«å®¹éã®ã¨ãããã£ããï¼ãã¨ãã価å¤ãä¸ãã£ããããCè¨èªãC++ãæ¡ç¨ãããã¨ãå¤ããªã£ã¦ãã¾ãã
ãããããã§ããªã人ãèæ ®ããã°ãå·¥æ°ãç¡é大ã«ãªãã®ã§ãã¬ã¼ããªãã®é¢ä¿ã¯æããã¡ã¾ãããã¤ã¾ããããããã®ãã¬ã¼ããªãã®é¢ä¿ãæããããªãã¨æããã®ã§ããã°ãããããã®ã¹ãã«ã足ããªãã¨ãããã¨ã証æãã¦ãã¾ãã¾ãã
SQLã®æãé«ç´ãªé¨å
ãSQLã®ã©ããé«ç´ãã¨ããã¨ãã¢ã«ã´ãªãºã ããªãã¨ããã§ãã
ãä¾ãã°ã
ããããSELECT * FROM TABLE_A WHERE KBN = '1';
ãã¨ããSQLãè¦ã¦ã¿ã¾ãããã
ããã®åç´ãªSQLã§ããKBNï¼TABLE_A_IDXï¼ã«ã¤ã³ããã¯ã¹ããã£ãå ´åãå¦çã¤ã¡ã¼ã¸ã¯ããã以ä¸ã®2ã¤ã«ãªãã¾ããï¼ããã¾ã§ã¤ã¡ã¼ã¸ã§ãï¼
Aãã¿ã¼ã³
ãreadSet = TABLE_A_IDX.Seek('1');
ã
ãfor (Object row : readSet){
ãããkey = row("KEY").Value;
ãããreturnSet.add(TABLE_A.Seek(key));
ã}
ã
ãretun returnSet;
Bãã¿ã¼ã³
ãfor (Object row : TABLE_A){
ãããif(row("KBN").Value == "1"){
ãããããreturnSet.add(row);
ããã}
ã}
ã
ãretun returnSet;
ãã©ã¡ãã®ã¢ã«ã´ãªãºã ã§ãã¼ã¿ãåå¾ãããã¨ããã®ã¯ããªããã£ãã¤ã¶ä»»ãã§ãSQLã§ã¯ã¢ã«ã´ãªãºã ãæ¸ããªãã¦ã欲ããçµæãæé©ãªã¢ã«ã´ãªãºã ã使ã£ã¦å¾ããã¨ãã§ãã¾ãããªããã£ãã¤ã¶ã¯ãã³ã³ãã¤ã«åã«ãAãã¿ã¼ã³ãBãã¿ã¼ã³ã®ãããã§ã§ã³ã³ãã¤ã«ãããããã¼ã¿ã®åæ£ãèæ ®ãã¦æ±ºãã¾ããè¤éãªå¦çã«ãªã£ãããæ°åãæ°ç¾ã®ãã¿ã¼ã³ã®ã¢ã«ã´ãªãºã ã®ä¸ããä¸ã¤ãé¸ã¶ãã¨ã«ãªãã§ãããã
ããã®ããã«ã人éãæ¸ããã½ã¼ã¹ããããã¼ã¿ï¼ç¶æ³ï¼ã«å¿ãã¦éã£ãã¢ã«ã´ãªãºã ãä½ãåºãã³ã³ãã¤ã«ãã¦ãããè¨èªã¯ãæ®åãã¦ããè¨èªã®ä¸ã§ã¯SQLã ãã§ãSQLã¯æãé«ç´è¨èªãªã®ã§ãã
ãåé¢ããã®ã¢ã«ã´ãªãºã ãä½ãã¨ããå¦çã¯ãé常ã«è¤éã§éãå¦çã«ãªãã¾ãã
ãRDBMSï¼SQLï¼ã使ãã¨ããã®éãå¦çãéããã¨ã«ãªããããRDBMSï¼SQLï¼ã¯å¤§å¤é ãã®ã§ãããã®é ãRDBMSãæ¢ãã¦ä½¿ã以ä¸ã¯ãSQLã使ãããªããã°ããã¨ã¯è¨ããªãããããä½ç´ã®è¨èªã§ã¢ã«ã´ãªãºã ãæ¸ãããã¨ãããªãã°ãRDBMSã®éãå¦çãã·ã§ã¼ãã«ããããªããã°æå³ããªããã¤ã¾ããNoSQLãæ¡ç¨ããå¿ è¦ããã訳ã§ãã
ãJavaã®ããã¸ã§ã¯ãã§ãã©ããã¦ãããã©ã¼ãã³ã¹ãåºãªãé¨åããã©ããã¦ãJavaã§ã¯ã§ããªããã·ã³ããã®å¦çãC++ã§æ¸ããã¨ã¯ããã§ããããããããC++ã§ã¡ã¤ã³ã®ã¢ã«ã´ãªãºã ãæ¸ããããã«ããã¯ã®é¨åã§Javaã®ã¢ã¸ã¥ã¼ã«ãå¼ã¶ã¨ããã®ã¯ãæ®éã¯ããå¾ãªãããããªãã¨ããããªãã¨ã¦ã¤ããªã馬鹿ã§ãã
ãã¨ããããSQLã«ããã¦ã¯ãã®ãããªé¦¬é¹¿ããæ§é ãæ®éã«è¦ããããã¤ã¾ããã¢ã«ã´ãªãºã ãJavaãªã©ã§æ¸ããªããããªããã¤ããã¼ã¿ã¢ã¯ã»ã¹ã«SQLã¨ããéãé«ç´è¨èªã使ã£ã¦ãããããããæ£ãããã¨ä¸»å¼µããã®ã¯ããèªåã¯ã¨ã¦ãããã¨ã¯å¼ã¹ãªã馬鹿ã§ããã¨å®£è¨ãã¦ãããããªãã®ã§ãããããããé£ä¸ã絡ãã§æ¥ãã®ã¯æ¯åº¦ã®ãã¨ãªããããããæã¦ããããªãã
ä½ã¨ãã¬ã¼ããªããããã
ãä½ç´è¨èªã¨é«ç´è¨èªãã²ã£ããè¿ãã¨ãçè«çã«ã¯ããã©ã¼ãã³ã¹ã¨å·¥æ°ããã¬ã¼ããªãã®é¢ä¿ã«ãªããä½åº¦ãç¹°ãè¿ãã¦ããã¨ãããSQLã使ããªãæ¹éãã¨ããã®ã§ããã°ãKVSãªã©ã®NoSQLãå©ç¨ããå¿ è¦ãããã®ã§ãããRDBMSã使ããªãããSQLã使ããªãï¼åç´ãªSQLã ãã使ãï¼æ¹éãã¨ããã®ã¯ãä½ã¨ä½ããã¬ã¼ããªããã¦ããã®ãï¼
ãä¾ãã°ãç¾å®åé¡ã¨ãã¦ãç¾å¨ã®ã·ã¹ãã ãã¢ã»ã³ããªè¨èªã§æ¸ããã¨ã¯ä¸å¯è½ã§ãããã
ãããé ã ï¼ å®ãï¼ä¾¡å¤ãããï¼ ï¼ éã ï¼ é«ãï¼é«ããã¦ä¾¡å¤ããªãï¼
ãã¨ãªãããã§ããã©ã¡ãã顧客ã«å¯¾ãã価å¤ããã¬ã¼ããªããã¦é¸æãã¦ãããç¾ç¶ã§ã¯ãã¢ã»ã³ããªè¨èªã§éããªãã¨ãã顧客ã«å¯¾ãã価å¤ã¯ãå¢ããå·¥æ°ï¼ã·ã¹ãã ã®ä¾¡æ ¼ï¼ãããéãã«å°ããã®ã§ãç¾å®çã«ã¯ä¸å¯è½ã¨å¤æãããããã§ããç¡å°½èµã®å·¥æ°ãæãã¦è¯ãã®ã§ããã°ãã¢ã»ã³ããªè¨èªã«ã§ããªããã¨ã¯ããã¾ããããOSã®ã«ã¼ãã«ãªã©ã¯å·¥æ°ãæãã£ã¦ããã¢ã»ã³ããªè¨èªã§ä½ããã¨ã«ãªãã§ãããã
ãRDBMSã使ããªãããSQLã使ããªãï¼åç´ãªSQLã ãã使ãï¼æ¹éãã¨ããã®ã¯ãæ¬æ¥ã¯ã
ãããé ã ï¼ é«ãï¼ä¾¡å¤ããªãï¼ ï¼ éã ï¼ å®ãï¼ä¾¡å¤ãé«ãï¼
ãã¨ãªããçè«çã«ã¯ãSQLã使ããªããã¨ãããã¨ã«ä¾¡å¤ã¯ãªãããã§ããªã人ã«åã£ã¦ã¯
ãããé ã ï¼ é«ãï¼ä¾¡å¤ãããï¼ ï¼ ã¹ãã«ã足ããã§ããªãï¼ä¾¡å¤ã¯ã¼ãï¼
ããã®å ´åãå³è¾ºã«ä¹ããã®ã¯æè¡è ã®é½åãããªããã¤ã¾ãã顧客ã«å¯¾ãã価å¤ã¨ãæè¡è ã®ã¹ãã«ä¸è¶³ããã¬ã¼ããªããã¦ããããããªä¸»å¼µããã¦ã¯æè¡è ã¨ãããã¨ãè¨ããªãã
ãç¾å®åé¡ã¨ãã¦ãã§ããªããã ããä»æ¹ãªãã®ã§ãããã©ããã¤ã¾ã§ãè¨ãã¹ãã§ã¯ãªãã§ãããã
SQLã¯ã¹ãã«å·®ã大ããããã
ãç¾å®åé¡ã¨ãã¦ã§ããªã人ãé常ã«å¤ããã§ãããªããã§ãã人ã¨ã§ããªã人æ å½ãåãããããªãã®ã§ããSQLãã§ãã人ã¯ãSQLãæ å½ããSQLãã§ããªããªãããããã§ããã¨ãããã¨ã¯ãä»ã®è¨èªã¯ã§ããã®ã§ããããããä»ã®è¨èªã ããæ å½ããã°ããã
ãSQLã¨ä»ã®è¨èªã¯èãæ¹ãå ¨ãéã«ãªãã®ã§ãåã人ãæ å½ããã®ã«ã¯ç¡çãããã®ã§ãã
ãSQLãã§ããªããã¨ã馬鹿ãªã®ã§ã¯ãªãããããèªä½ã«ä½ãåé¡ã¯ããã¾ããã
ãããããRDBMSã使ããªãããSQLã使ããªãï¼åç´ãªSQLã ãã使ãï¼æ¹éãã¨ããã¨ãã§ããªã馬鹿ãªæ¹éãç«ã¦ãã®ã¯ãSQLãã§ããªã人éã§ãããã®ã¨ãã§ããªãæ¹éãç«ã¦ããã¨ã馬鹿ãã¦ããã®ã§ãã
ãä»ã®è¨èªãã§ããªããã°ã·ã¹ãã ã¯ã§ããªããã©ã¡ããå¿ è¦ã§ãã
ãããããSQLã¨ã¯ä½ã§ã©ãæ±ãã¹ãããã¨ãããã¨ã¯ãå ¨å¡ãç解ããå¿ è¦ãããã§ãããããã®ç解ããªãããã«ãã·ã¹ãã ã®ã°ã©ã³ããã¶ã¤ã³ãæ¹éãã馬鹿ãªæ¹åã¸åããã®ã§ããã°ã大馬鹿è ã¨ããè¨ããããããã¾ããã