/* Read this into mysql with "\. initdb-mysql" when logged in as root
   to delete the old lxr database and create a new */ 

drop database lxr; 
create database lxr; 
use lxr;

/* symnum filenum */
create table files (
        filename        char(255) binary not null,
        revision        char(255) binary not null,
        fileid          int not null auto_increment,
        primary key     (fileid) /*,
        unique          (filename, revision) */

);

create table symbols (
        symname         char(255) binary not null,
        symid           int not null auto_increment,
        primary key     (symid),
        unique          (symname)

);

create table indexes (
        symid           int not null references symbols,
        fileid          int not null references files,
        line            int not null,
        type            char(1) binary,
        relsym          int          references symbols
);

create table releases 
        (fileid         int not null references files,
        release         char(255) binary not null,
        primary key     (fileid,release)
);

create table useage
        (fileid         int not null    references files,
        line            int not null,
        symid           int not null    references symbols
);

create table status
        (fileid         int not null references files,
        status          int,
        primary key     (fileid)
);


create index indexindex on indexes  (symid) ;
create unique index symbolindex on symbols  (symname) ;
create index useageindex on useage  (symid) ;

grant all on lxr.* to lxr@localhost;
