0% found this document useful (0 votes)
2 views

console

The document outlines SQL commands to create a 'Library' database, including tables for 'User', 'Document', and 'User_Book'. It specifies the structure of each table, including fields and data types, and establishes foreign key relationships. Additionally, it includes an insertion command for an admin user into the 'User' table.

Uploaded by

Nguyen Huu Hieu
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)
2 views

console

The document outlines SQL commands to create a 'Library' database, including tables for 'User', 'Document', and 'User_Book'. It specifies the structure of each table, including fields and data types, and establishes foreign key relationships. Additionally, it includes an insertion command for an admin user into the 'User' table.

Uploaded by

Nguyen Huu Hieu
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

CREATE DATABASE IF NOT EXISTS Library;

USE Library;

drop table User_Book;


DROP table Document;
Drop table User;
create table if not exists User (
username varchar(100) not null,
primary key (username),
password varchar(100) not null,
fullname varchar(100) not null,
borrowed int,
type varchar(5) not null
);
CREATE TABLE IF NOT EXISTS Document(
ISBN int NOT NULL auto_increment,
Title VARCHAR(255) NOT NULL ,
Author VARCHAR(100) NOT NULL ,
Year INT(10),
imageData BLOB,
ImageURL VARCHAR(255),
remaining int not null,
categories varchar(255),
description text,
publishDate varchar(100),
PRIMARY KEY (ISBN)
);

create table User_Book(


ISBN int NOT NULL ,
title varchar(255) not null ,
username varchar(100) not null,
Author VARCHAR(100) NOT NULL ,
borrowDate date,
returnDate date,
foreign key (username) references user(username),
foreign key (ISBN) references Document(ISBN)
);

INSERT INTO User (username, password, fullname, type, borrowed)


value ('admin', '1', 'anhtuyen', 'A', 0);
# insert ignore into User (username, password, fullname)
# values ('anh15082005', '123456', 'soobin');
# SELECT * FROM Document
# SELECT * FROM Document WHERE Title LIKE '%Lose%'
select * from user_book;

You might also like