Library Management System: Database Project - Part IV - Database Implementation


  LMS
  Library Management System for Imaginary University
  2nd year Database Project


Data Definition Language (DDL) of the database.

create table items
    (
     id                  INT PRIMARY KEY,
     borrowed            boolean,
     received_as         varchar(50)    
        );
   
create table book_details
    (
     ISBN                varchar(15) PRIMARY KEY,
     title               varchar(50) not null,
     edition             varchar(15),
     publisher           varchar(50),
     category            varchar(50),
     price               float(7,2)
        );
       
create table books
    (
     item_id         int PRIMARY KEY,
     ISBN            varchar(15) ,   
     foreign key (item_id) references items(id),
     foreign key (ISBN) references book_details(ISBN)
        );   

create table cd_details
    (
     ISSN                 varchar(15) PRIMARY KEY,
     title                varchar(50) not null,
     edition              varchar(15),
     publisher            varchar(50),
     category             varchar(50),
     price                float(7,2)
        );

create table cds
    (
     item_id           int PRIMARY KEY,
     ISSN              varchar(15) ,
     foreign key (item_id) references items(id),
     foreign key (ISSN) references cd_details(ISSN)
        );

   
create table members
    (
     member_index       varchar(10)  PRIMARY KEY,
     first_name         varchar(50) not null,
     last_name          varchar(50) not null,
     department         varchar(20) not null,
     password           varchar(15) not null,
     email              varchar(50),
     number_of_books_allowed int
        );

create table students
    (
     student_index      varchar(10)  PRIMARY KEY,
     batch              varchar(5) not null,
     total_fine         int,
     registered_date   date,
     foreign key (student_index) references members(member_index)
        );
   
create table staff
    (
     staff_index           varchar(10)  PRIMARY KEY,
     year_of_appoinment    DATE,
     position              varchar(20) not null,
     foreign key (staff_index) references members(member_index)
        );
   
create table authors
    (
    ISBN                  varchar(15)  PRIMARY KEY,
    author_name_1         varchar(20) not null,
    author_name_2         varchar(20),
    author_name_3         varchar(20),
    author_name_4         varchar(20),
    foreign key (ISBN)    references book_details(ISBN)
       );

create table borrows
    (
     member_index         varchar(10),
     item_id              int,
     borrowed_date        DATE not null,
     fine                 float(7,2),
     remarks              varchar(50),
     foreign key (member_index) references members(member_index),
     foreign key (item_id) references items(id),
     primary key (member_index,item_id)
        );
   
create table locations
    (
     id                INT PRIMARY KEY,
     shelve_ID         varchar(6),
     row_number        int,
     section           varchar(15) not null
        );
   
create table item_is_at
    (
     ISBN             varchar(15) PRIMARY KEY,
     location_id      int,   
     foreign key (location_id) references locations(id),
     foreign key (ISBN) references book_details(ISBN)
        );
   
create table operator
    (id               varchar(10) PRIMARY KEY,
     username         varchar(50) not null,
     password         varchar(15) not null,
     email            Varchar(128) not null,
     position         varchar(64)    
        );

Comments

Popular posts from this blog

Library Management System: Database Project - Part III - Database Design

Library Management System: Database Project - Part I - Introduction

Library Management System: Database Project - Part V - Finalize Database