FrontPage|FindPage|TitleIndex|RecentChanges|RSS Hash Database
 

µé¾î°¡´Â ±Û #


¿Â¶óÀΰÔÀÓ È¤Àº ´Ù¸¥ ÀÎÅÍ³Ý ¼­ºñ½º¸¦ À§ÇÑ µ¥ÀÌÅͺ£À̽º´Â ¾î¶² °ÍÀ» ¼±ÅÃÇÒ±î? ¸¹Àº °³¹ßÀÚµéÀÌ M$SQLÀ̳ª ¿À¶óŬ°°Àº »ó¿ë RDB¸¦ ¼±ÅÃÇÏÁö¸¸, ºÒÇàÇÏ°Ôµµ ºñ¿ë °è»êÀº ÀüÇô ÇÏÁö ¾Ê´Âµí ÇÏ´Ù. M$-SQL ¼­¹ö¸¦ ¾µ °æ¿ì¿¡,

  1. Windows Server¸¦ »ç¶ó. CPU´ç ÇÑ°³¾¿ »ç¾ßÇÑ´Ù.
  2. MS-SQL Server¸¦ »ç¶ó. ¿ª½Ã CPU´ç ÇÑ°³¾¿ »ç¾ßÇÑ´Ù.
  3. Windows Server Clinet Access Lisence¸¦ »ç¶ó. ÃÖ¼Ò 5°³´Â »ç¾ßÇÑ´Ù.
  4. MS-SQL CALÀ» »ç¶ó. ¿ª½Ã 5°³´Â »ç¾ßÇÑ´Ù.
  5. DB¼­¹ö°¡ ¿©·¯´ëÀΰ¡? ´ë¼öº°·Î 1-4 ¸¸Å­ »ç¶ó.
´ë´ç ¼ö¹é¸¸¿øÀÇ ºñ¿ëÀÌ µç´Ù. ºÒÇàÈ÷µµ °³¹ßÀÚ´Â ºñ¿ë¿¡ ½Å°æ¾²Áö ¾ÊÀ¸¸ç, ÀÌ¿Í´Â Á¤ ¹Ý´ë·Î ÇÁ·ÎÁ§Æ® ÀçÁ¤´ã´çÀÚ´Â ¾ÇÈ­µÇ´Â ¼öÀͼº¿¡ ÇÇ´«¹°À» È긱 °ÍÀÌ´Ù. ¹¹ Á¦ °ª ´ÙÁÖ°í »ç¼­ ¾²´Â ȸ»ç°¡ ÀÖÀ»±î ½ÍÁö¸¸, °ÔÀÓÀÌ Àα⸦ ²ø°Í °°À¸¸é - ¸Å½ºÄÄ¿¡ À̸§ÀÌ Á¾Á¾ µîÀåÇÒ¶óÄ¡¸é - ±Í½Å°°Àº ºÒ¹ý¼ÒÇÁÆ®¿þ¾î ´Ü¼Ó¹ÝÀÌ ¼ö½Ã·Î Ãâ¸ôÇÒ °ÍÀÌ´Ù. °³¹ß´Ü°è¶ó¸é ¸ð¸£°ÚÁö¸¸, °á±¹¿£ ´Ù »ç¾ß ÇÑ´Ù. ÇØ°áÃ¥À» »ý°¢ÇØ º¸ÀÚ.

  1. È¿À²À» ÃÖ´ëÇÑ ¿Ã·Á¼­, ´ë¼ö¸¦ ÂáÀδÙ.
  2. °øÂ¥ DB¸¦ ±¸ÇØ´Ù ¾´´Ù.
  3. Á÷Á¢ ¸¸µç´Ù.
°øÂ¥ DB¶ó¸é, ¸®´ª½ºÀÇ mysqlÀÌ ÀÖ´Ù¸¸ °æÇè»ó ¾ÈÁ¤ÀûÀÌÁö ¸øÇÏ´Ù. safe_mysqld °°Àº ½ºÅ©¸³Æ®°¡ ÇÊ¿ä¾øÀ» Á¤µµ·Î µðºñ¼­¹ö´Â ¾ÈÁ¤ÀûÀ̾î¾ß ÇÑ´Ù. °øÂ¥DBÁß¿¡¼­ ÆÄÀÏÀ» ÀÌ¿ëÇÑ µ¥ÀÌÅͺ£À̽º gdbmÀ» ÀÌ¿ëÇÏ´Â DB Ŭ·¡½º Á¦ÀÛÀ» ÇÏ·Á ÇÑ´Ù.

GNU DBM : Ŭ¸¯ gdbm


Concepts #


ÀÌ ±Û¿¡¼­ ¸¸µå·Á´Â DB Ŭ·¡½º´Â TDB¶ó°í À̸§ºÙÀ̱â·Î Çß´Ù.

  1. Å°+µ¥ÀÌÅÍ : Çʵå(ȤÀº Ä÷³)´Â ¾ø´Ù. Å°°ª°ú Å°°ª¿¡ ºÙ¾î°¡´Â µ¥ÀÌÅͷθ¸ ±¸¼ºµÈ´Ù. ÀúÀåÇÏ°íÀÚ ÇÏ´Â ³»¿ëµéÀº ÁË´Ù ¹¶¶×±×·Á¼­ ÇϳªÀÇ µ¥ÀÌÅÍ·Î °ü¸®ÇØ¾ß ÇÑ´Ù.
  2. NO_INDEX : ISAM Çü½ÄÀÇ À妽ºÆÄÀÏÀº µÎÁö ¾Ê´Â´Ù. HashÅ°·Î Á¢±ÙÇÑ´Ù.
  3. FILE DB : Á÷Á¢ ÆÄÀÏÀ» ÀÌ¿ëÇÑ´Ù. ÆÄÀÏ »çÀÌÁî°¡ ³Ê¹« Ä¿Áú ¿ì·Á°¡ Àִµ¥ ´ÙÀ½ ¹öÀü¿¡¼­ ÇØ°áÇÑ´Ù.

gdbm Ŭ·¡½º Á¦ÀÛ #

class TDB
{
protected :
    char dbname[MAX_DIR];

public :
    TDB(const char *ldbname)
    {
        strcpy(dbname, ldbname);
    };

    int Read(const char *lkey, char *outdata);
    int Update(const char *lkey, const char *data, const int size);
    int Update(const char *lkey, const char *data)
    {
        return Update(lkey, data, strlen(data)+1); // include NULL
    };
}; 

Ŭ·¡½º ¼±¾ðÀº Ưº°ÇÒ°Ô ¾ø´Ù.

int TDB::Read(const char *lkey, char *outdata)
{
    GDBM_FILE dbf = gdbm_open(dbname, SIZE_DBBLOCK, GDBM_READER, 00600, 0);

    if(dbf == NULL) return -1;

    datum dkey = { (char *)lkey, strlen(lkey) };
    datum ddata = gdbm_fetch(dbf, dkey);

    memcpy(outdata, ddata.dptr, ddata.dsize);
    int size = ddata.dsize;

    gdbm_close(dbf);

    return size;
}

int TDB::Update(const char *lkey, const char *data, const int size)
{
    GDBM_FILE dbf = gdbm_open(dbname, SIZE_DBBLOCK, GDBM_WRITER, 00600, 0);

    if(dbf == NULL) return -1;

    datum dkey = { (char *)lkey, strlen(lkey) };
    datum ddata = { (char *)data, size };

    int result = gdbm_store(dbf, dkey, ddata, GDBM_REPLACE);
    gdbm_close(dbf);

    return result;
} 

Read¿Í Update ÇÔ¼ö. ÇÔ¼ö°¡ È£ÃâµÉ¶§¸¶´Ù db¸¦ ¿­°í ´Ý°í¸¦ ¹Ýº¹Çϵµ·Ï Çߴµ¥ ¼º´É¿¡¼­´Â ¼ÕÇØ°¡ ÀÖÁö¸¸, ¾ÈÁ¤¼ºÀ» ¿ì¼±À¸·Î Çϱâ À§Çؼ­ÀÌ´Ù. gdbm ¸Å´º¾óÀ» Àо¸é, Writer ¸ðµå·Î ¿ÀÇÂÇÒ°æ¿ì µ¿½Ã¿¡ 1°³ÀÇ ÇÁ·Î±×·¥¸¸ÀÌ ÀÌ ÆÄÀÏÀ» ¾ï¼¼½º ÇÒ ¼ö Àִµ¥, ±×·± µ¿ÀÛ¹æ½Ä¶§¹®¿¡ read¿Í write °¢°¢¿¡¼­ ÆÄÀÏÀ» ´Ù¸¥ ¸ðµå·Î ¿ÀÇÂÇϵµ·Ï ÇÏ¿´´Ù.

Test #

#include <stdio.h>
#include "tdb.h"

int main()
{
    TDB a("test.db");

    a.Update("test1", "Hello World\n");

    char buf[1000];
    a.Read("test1", buf);

    printf("%s", buf);
}


Replace original file
Rename if it already exist

File nameSize(byte)Date
 .. 2007-01-09
tdb.tgz6722004-07-03
Total 1 files
Password:

last modified 2004-07-28 17:13:48
EditText|FindPage|DeletePage|LikePages|UploadedFiles|UploadFile|