Using mysql to design a book management system (3)--C language source code of the book management system

I have been changing the code for the past few days, but there may still be some small bugs. If I find it at that time, I hope you will give me some advice. I am just a freshman rookie. . . I also hope that the big guys don't spray me...
Because I also bought Alibaba Cloud's database, so I use Alibaba Cloud's connection here. Of course, I can also use my own local, but there is a disadvantage, that is, other users Difficult to access, (and certainly not impossible)

When using, you need to modify the following content

1.c source code is mainly to modify this place
mysql_real_connect(mysql, "address", "user name", "password", "library", 3306, NULL, 0);
if the address is to be modified according to your database usage , if it is a local database, it is usually localhost. If it is an Aliyun database, you can set the external network address in the database instance, which is probably rm-2ze9g5if8j748p237bi.mysql.rds.aliyuncs.com, just put this directly in the address Inside, the user name and password need not be said, and then the library is the database I use, if I use it, I hope it can be consistent, 3306 is the default

create database library;
use library;

2. Database structure
bookThis is the book data table, which is used to store book information, where id is the primary key and auto-incrementing
remains is the remaining quantity, stillalive is whether it is on the bookshelf, year is the publication time, and fans are the popularity

CREATE TABLE `book` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(32) DEFAULT NULL,
  `writer` varchar(32) DEFAULT NULL,
  `type` varchar(32) DEFAULT NULL,
  `remain` int(11) DEFAULT NULL,
  `fans` int(11) unsigned DEFAULT '0',
  `year` int(11) DEFAULT NULL,
  `stillalive` int(11) unsigned DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8;

insert image description hereThis is the borrow data table, which is used to store the currently borrowed books. The
set return time is 1 month

CREATE TABLE `borrow` (
  `username` varchar(32) DEFAULT NULL,
  `bookname` varchar(32) DEFAULT NULL,
  `borrowtime` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `duetime` varchar(32) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

insert image description here
This is the borrow_list that stores all the borrowed records, the id primary key is incremented automatically, and the backtime records the real return time of the user

CREATE TABLE `borrow_list` (
  `id` int(32) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `bookname` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `borrowtime` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `backtime` varchar(32) DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;

insert image description hereThis is the users data table, the password is not encrypted, of course, you can choose to encrypt
it. In my program, only the user name is allowed to be the root user as the administrator, and rematintime is the remaining number of borrowings.

CREATE TABLE `users` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(32) DEFAULT NULL,
  `password` varchar(32) DEFAULT NULL,
  `sex` varchar(5) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '1' COMMENT '男或者女',
  `workplace` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `remaintime` int(11) unsigned DEFAULT '5',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;

The code may have an ugly user interface. . . I am sorry. . I hope you don't hate it

The function is as follows

1. Log in, 2. Register, 3. Log out, 4. Log out (this is at the login level)
1. Query service
2. Book data management service (only supports administrators),
3. Book borrowing service,
4. Book return service,
5. User information modification service,
6. Exit the service

1. Query service
{
1. Book title search,
2. Author search,
3. Category search
, 4. Fuzzy search,
5. Publication year search,
6. Display all current books,
{
1 book number ascending order
2 book number descending order
3 book title ascending order
4 Book title descending
5 Author name ascending
6 Author name descending
}
7. Query current user information,
8. Query book borrowing records,
9. Exit query service\n");
}

2. Book data management service:
{
1. Add books,
2. Delete books, (through specific methods)
{
1. id,
2. Whole book,
3. Author name,
4. Exit and delete
}
3. Modify book data ,
{
1. Book title,
2. Author name,
3. Remaining content,
4. Popularity
5. Publishing time,
6. Type,
7. Exit modification service
4. Display currently available books
{
1 ISBN ascending
2 ISBN descending
3 Book title Ascending
4 Book Title Descending
5 Author Name Ascending
6 Author Name Descending
}
5. Display all current user information,
6. Exit the book data management service
Three or four will not say
5. User information modification service,
{
1. User name modification,
2 .password modification,
3.gender modification,
4.unit modification,
5.exit map user information modification service
}

ok, in order to facilitate everyone to browse and download, I have uploaded it to github, and I will release updated information from time to time, and will also fix known bugs. I also hope that you will support the
book management system more.

By the way, I modified the structure of borrow_list, I hope you will pay attention to
backtimevarchar(32) DEFAULT NULL ,改成了backtimevarchar(32) DEFAULT 0,

If you have not configured the mysql structure, just follow the above operation, I have modified it
If you have configured the mysql structure before, you may need to modify it, the command is as follows

 alter table borrow_list alter column backtime set default 0;

If you have any questions, you can leave a message in time, thank you for your support

Related Posts