Click here to Skip to main content
14,734,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 3 tablese
table1 is tbl_members
table2 is tbl_library
table3 is tbl_borrowing

tbl_members hase this columns

idmebmer int autoincrement (primary key)
name varchar
adress varchar
tel varchar
email varchar

tbl_library hase this columns
idbook int autoincrement (primary key)
bookname varchar
bookauthor varchar
category varchar

tbl_borrowing hase this columns

idmebmer int autoincrement (primary key) 'this column is from foreign key from tbl_members '

idbook int autoincrement (foreign key) 'this column is from foreign key from tbl_library'

data_checkoutbook varchar ' the time where the user hase pickup the book from the library
data_retunbook varchar 'the time where the user must return the book to the library

i cane save data in table tbl_library and tbl_members but
how ken i save the date in tbl_borrowing for the user how has pick up a book
the user can only one book pick up

or how to i construk a database for a library menagment system

sorry for my english
WajihaAhmed 2-Jan-13 9:36am
Firstly, why you have auto-incremented the "idmebmer" and "idbook" in your "tbl_borrowing", any special reason?You just need an insert statement to acheive your goal.

1 solution

If the user can only borrow one book, then I would be tempted to incorporate the loan details into the user, but...
Your system won't work while you have the columns set to autoincrement - you can't directly set those fields as they are updated by SQL server itself - any attempt to insert or update those values will give you an exception. Since they are suppose to refer to the Member and the Book, You should remove the autoincrement from them.

Personally, I'm not fond of autoincrement values for specific item ids - I prefer to use Guids as they can be set by the VB/C# code when the row is created, rather than created by the SQL and then the value has to be found in order to apply any functions to it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900