0% found this document useful (0 votes)
6 views1 page

Project Code- Mysql

Uploaded by

sri.pranathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Project Code- Mysql

Uploaded by

sri.pranathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

-- Step 1: Create the Database

CREATE DATABASE IF NOT EXISTS library_db;


USE library_db;

-- Step 2: Create the Books Table


CREATE TABLE IF NOT EXISTS Books (
book_id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
author VARCHAR(255) NOT NULL,
category VARCHAR(255),
isbn VARCHAR(50),
availability BOOLEAN DEFAULT TRUE
);

-- Step 3: Create the Members Table


CREATE TABLE IF NOT EXISTS Members (
member_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
contact VARCHAR(50),
email VARCHAR(255),
membership_date DATE
);

-- Step 4: Create the Transactions Table


CREATE TABLE IF NOT EXISTS Transactions (
transaction_id INT AUTO_INCREMENT PRIMARY KEY,
book_id INT,
member_id INT,
issue_date DATE,
due_date DATE,
return_date DATE,
fine DECIMAL(5,2) DEFAULT 0,
FOREIGN KEY (book_id) REFERENCES Books(book_id),
FOREIGN KEY (member_id) REFERENCES Members(member_id)
);

You might also like