/* ============================================================ */
/*   Database name:  ADS                                        */
/*   DBMS name:      Microsoft SQL Server 6.x                   */
/*   Created on:     2/2/2001  5:51 PM                          */
/* ============================================================ */

/* ============================================================ */
/*   Table: USER_TYPE                                           */
/* ============================================================ */
create table USER_TYPE
(
    UT_ID          int                   not null,
    UT_NAME        varchar(127)          not null,
    constraint PK_USER_TYPE primary key (UT_ID)
)
go

/* ============================================================ */
/*   Table: USERS                                               */
/* ============================================================ */
create table USERS
(
    U_ID           int                   not null,
    UT_ID          int                   not null,
    U_FIRSTNAME    varchar(127)          not null,
    U_LASTNAME     varchar(127)          not null,
    U_PW           varchar(31)           not null,
    U_DATE         datetime              null    ,
    constraint PK_USERS primary key (U_ID)
)
go

/* ============================================================ */
/*   Index: USER_USERTYPE_FK                                    */
/* ============================================================ */
create index USER_USERTYPE_FK on USERS (UT_ID)
go

/* ============================================================ */
/*   Table: ARTEFAKT                                            */
/* ============================================================ */
create table ARTEFAKT
(
    A_ID           int                   not null,
    U_ID           int                   not null,
    A_NAME         varchar(127)          not null,
    A_DATE         datetime              not null,
    A_PIC_PATH     varchar(255)          null    ,
    A_DESCRIPTION  varchar(255)          null    ,
    A_FUNDORT      varchar(127)          null    ,
    A_FUNDDATE     datetime              null    ,
    A_FOUNDBY      varchar(127)          null    ,
    constraint PK_ARTEFAKT primary key (A_ID)
)
go

/* ============================================================ */
/*   Index: ENTERED_BY_FK                                       */
/* ============================================================ */
create index ENTERED_BY_FK on ARTEFAKT (U_ID)
go

alter table USERS
    add constraint FK_USERS_USER_USER_USER_TYP foreign key  (UT_ID)
       references USER_TYPE (UT_ID)
go

alter table ARTEFAKT
    add constraint FK_ARTEFAKT_ENTERED_B_USERS foreign key  (U_ID)
       references USERS (U_ID)
go

