Database - Using foreign key for multiple row -


i creating database using several tables.

basically it's prototype of campus' library database has book , student information. program i'm making has borrow, , return functions now. i'm planning put them way :

for table student :

 create table student(  id int not null primary key,  student_name varchar(30),  student_id integer not null,  book_id integer,  foreign key (book_id) references book(id) ) 

and table book :

create table book(  id int not null primary key,  book_title varchar(30),  book_total integer not null,  book_left integer not null ) 

a problem arise when student allowed borrow maximum of 3 books. example book1, book2, , book3. should here?

first adding 2 columns : book_borrowed, , book_quota in table student check quota, right?

second, solution adding more books borrowed student's information? should add table storing id(student), , id(book) show relationship? or (if possible) use book_id column store multiple id(book) example

id 1 student_name kevin student_id 12345 book_id 1,2,3 //this? 


Comments