Sitemap
Lymah

Lymah

Software Engieneer || Technical Writer || Open Source Contributor ||

DATABASE DESIGN WITH SQL CODE

6 min readAug 14, 2023

DATABASE DESIGN FOR LIBRARY MANAGEMENT SYSTEM USING MYSQL

Press enter or click to view image in full size
You might not think that programmers are artists, but programming is an extremely creative profession

What is a library?

A library is a collection of organized information and resources that are made accessible to a well-defined community/universities/colleges for borrowing or reference sake. The collection of resources and information is provided in digital or physical format in either a building or room or in a virtual space or both ways.

Library’s resources and collections may include books(e.g genres, fictions, non-fiction, reference books, textbooks,etc), E-books(books that can access on electronic devices), journals and periodicals(regularly published magazines, newspapers, academic journals,etc), audiovisual materials(e.g CDs, DVDs, documentaries, music, audio recordings, educational videos,etc), reference materials(e.g dictionaries, encyclopedias, atlases, etc), special collections(e.g rare books, manuscripts, archives, and historical documents that holds cultural or historical significance), theses and dissertations(i.e research papers submitted by students as part of their academic degrees), maps(i.e graphical materials including maps and atlases), digital resources(e.g online databases, e-journals, e-books, etc), artifacts and exhibits, multimedia stations, children’s and young adult collections, microforms, government publications, digital archives, educational kits and games, language learning materials, local history and genealogy,etc

These are just a few examples of the diverse resources and collections that libraries may offer to their patrons. The specific resources available can vary widely depending on the type of library (public, academic, special, etc.) and its focus.

The aim of this system is to develop a new system that will convey the everlasting solutions to manual-based operations and to make available a channel through which staff maintains the record easily and customers can access the information about the library at whatever place they might find themselves.

Library Management System: allows the user to store book details and find customer details. The system is strong enough to withstand regressive yearly operations under conditions where the database is maintained and cleared over a certain time span. The implementation of the system in the organization will considerably reduce data entry, time and also provide readily calculated reports.

OBJECTIVE

It keeps track of all the information about the books in the library, their cost, status, and total number of books available in the library. The user will find it easy in this automated system rather than using a manual writing system. The system contains a database where all the information will be stored safely.

Data types and their description

INT: Represents whole numbers, typically with a specified range (e.g., INT, SMALLINT, BIGINT). Example: INT for integers between -2,147,483,648 and 2,147,483,647.

FLOAT: Represents floating-point numbers with decimal precision. Example: FLOAT(10, 2) for a number with 10 digits, 2 of which are after the decimal point.

CHAR or VARCHAR: Represents character strings of fixed (CHAR) or variable (VARCHAR) lengths. Example: VARCHAR(255) for a variable-length string with a maximum of 255 characters.

BOOLEAN or BIT: Represents logical values, usually TRUE or FALSE, or 0 or 1.

DATE: Represents a date without a time component. Example: DATE for dates like ‘2023–08–13’.

TIME: Represents a time without a date component. Example: TIME for times like ‘12:30:00’.

DATETIME or TIMESTAMP: Represents both date and time. Example: TIMESTAMP for date and time like ‘2023–08–13 12:30:00’.

NULL: Represents the absence of a value or unknown data.

INTERVAL: Represents a time interval.

ENUM: Represents a set of predefined values that a column can take.

JSON: Represents JSON-formatted data.

ARRAY: Represents an ordered collection of elements of the same data type.

XML: Represents XML-formatted data.

Data Requirements

Entities

BRANCH

EMPLOYEE

CUSTOMER

ISSUE STATUS

RETURN STATUS

BOOKS

Attributes

BRANCH

manager_id

branch_id

address

contact_no

branch_no

street

City

state

zipcode

CUSTOMER

customer_id

books_issued

name

address

registration_date

ISSUE STATUS

issue_book_name

issue_id

issue_date

ISBN

customer_id

Get Lymah’s stories in your inbox

Join Medium for free to get updates from this writer.

book_id

RETURN STATUS

return_id

return_date

customer_id

return_book_name

ISBN

BOOKS

bookk_id

ISBN

title

category

rental_price

author

publisher

status

RELATIONSHIPS — CARDINALITY

MANAGER manages the BRANCH (1-N)

CUSTOMER registers in the respective BRANCH (N-1)

CUSTOMER issues BOOKS (1-N)

CUSTOMER returns BOOKS (N-1)

EMPLOYEE updates BOOKS (N-N)

Entity — Relationship — Diagram

Entity Relationship Diagram is a modern database software engineering to illustrate the logical structure of the database. It is a relational schema database modeling method used to Model a system and appropriately. This approach is commonly used in database design. The diagram created using this method is called ER diagram.

The ER diagram depicts the various relationships among entities, considering each object as an entity. The entity is represented as a rectangle shape and the relationship is represented as a diamond shape. It depicts the relationship between data objects.

The ER diagram is the notation that is used to conduct the data modeling activity

Press enter or click to view image in full size
An ER diagram

SCHEMA DIAGRAM

A schema is the structure behind data organization. It is a visual representation of how different table relationships enable the schema’s underlying mission business rules for which the database is created. Database schema defines its entities and the relationship among them.

It contains a descriptive detail of the database, which can be depicted by means of schema diagrams. It is the database designers who design the schema to help programmers understand the data and make it useful.

Schema diagrams have an important function because they force database developers to transpose ideas to paper. This provides an overview of the entire database while facilitating future database administrator work.

CREATING DATABASE USING MYSQL

Press enter or click to view image in full size
SQL queries for the creation of project names in the database some tables
Press enter or click to view image in full size
SQL queries where I created other tables
Press enter or click to view image in full size
These are the tables
Press enter or click to view image in full size
Values inside books table
Press enter or click to view image in full size
The values inside the customer table
Press enter or click to view image in full size
The values inside the branch table
Press enter or click to view image in full size
The values inside the employee table
Press enter or click to view image in full size
The values inside the issue_status table
Press enter or click to view image in full size
The values inside return_status
Press enter or click to view image in full size
Follow by the queries above
Press enter or click to view image in full size
This is the code snippet
Press enter or click to view image in full size
I altered those tables
Press enter or click to view image in full size
I added values to the branch table
Press enter or click to view image in full size
I added values to the customer table
Press enter or click to view image in full size
I added values to issue_status and return_status tables

TEST QUERIES

Press enter or click to view image in full size
1.
Press enter or click to view image in full size
2.

CONCLUSION

In conclusion, this database project has successfully demonstrated the design and implementation of a comprehensive library management system. Through the meticulous creation of tables for books, employees, branches, customers, issue statuses, and return statuses, we’ve built a robust foundation for efficiently managing various aspects of a library’s operations.

By meticulously structuring relationships between these tables using primary keys, foreign keys, and well-defined constraints, we’ve ensured data integrity and smooth navigation through the database. The project’s success is further reflected in the seamless execution of complex queries, enabling us to extract valuable insights such as identifying customers who have borrowed comedy books or tracking issue and return transactions.

This library management system is not only functional but also scalable and adaptable. Its well-designed structure allows for easy expansion and incorporation of new features in the future. Whether it’s adding new book categories, extending employee roles, or enhancing customer interactions, the database architecture provides a solid framework for growth.

You can interact with the project code on my GitHub here.

In summary, this project showcases the power of database design in streamlining library operations and enhancing user experiences. It underscores the significance of organized data management, efficient querying, and the potential for continuous improvement. By successfully creating a comprehensive library management system, this project serves as a testament to the effective utilization of database technology in real-world scenarios.

--

--

Lymah
Lymah

Written by Lymah

Software Engieneer || Technical Writer || Open Source Contributor ||