Results 1 to 8 of 8

Thread: Double Booking

  1. #1
    Join Date
    Jan 2004
    Posts
    106

    Unanswered: Double Booking

    I am creating a library databse with three main tables: books, loan, instance of book, students.
    i need to come up with a way of making sure that the same book cannot be borrowed more than once at the same time. please help
    thanks!

  2. #2
    Join Date
    Jan 2004
    Location
    OHIO
    Posts
    75

    Re: Double Booking

    Originally posted by craig_dixon
    I am creating a library databse with three main tables: books, loan, instance of book, students.
    thanks!
    Well, first thing is that it looks like you are working with 4 tables not 3

    As of now, what does your table relationships look like?

    baf

  3. #3
    Join Date
    Jan 2004
    Posts
    106

    Re: Double Booking

    Originally posted by ironchef
    Well, first thing is that it looks like you are working with 4 tables not 3

    As of now, what does your table relationships look like?

    baf
    RELATIONSHIPS
    i have the isbn number (primary key) in the book table linked to the isbn in the instance of book,
    book number (primary key) in the instance table to book number in loan table,
    and the student ID filed (primary key) in the student table liked to the student ID field in the loan table

  4. #4
    Join Date
    Oct 2003
    Location
    US
    Posts
    343

    Re: Double Booking

    Yuo have to understand that there are two entities involved in your case books and students. Since a book can be borrowed by many students over a period and a student can borrow many books so you have to create a many to many relationship between the two. This can be done by using another table in between which you can say as loan. This table will contain all the information for that particular instance of book being loaned out to a particular student.

    To prevent same book to be sent out multiple times, you can create a flag field in books table which can be set or reset depending if the book is out or in.


    Originally posted by craig_dixon
    RELATIONSHIPS
    i have the isbn number (primary key) in the book table linked to the isbn in the instance of book,
    book number (primary key) in the instance table to book number in loan table,
    and the student ID filed (primary key) in the student table liked to the student ID field in the loan table

  5. #5
    Join Date
    Jan 2004
    Posts
    106

    Re: Double Booking

    Originally posted by khan
    Yuo have to understand that there are two entities involved in your case books and students. Since a book can be borrowed by many students over a period and a student can borrow many books so you have to create a many to many relationship between the two. This can be done by using another table in between which you can say as loan. This table will contain all the information for that particular instance of book being loaned out to a particular student.

    To prevent same book to be sent out multiple times, you can create a flag field in books table which can be set or reset depending if the book is out or in.
    i already hav a loan table with a link, i just need to know how to prevent double booking
    thanks!

  6. #6
    Join Date
    Oct 2003
    Location
    US
    Posts
    343

    Re: Double Booking

    Read my senod para in my previous post..


    Originally posted by craig_dixon
    i already hav a loan table with a link, i just need to know how to prevent double booking
    thanks!

  7. #7
    Join Date
    Oct 2003
    Posts
    706

    Exclamation

    This is where 'transactions' come into play. Please refer to the Access documents where they explain not only the mechanics of how to use them, but the philosophy as well. (So this isn't an "RTFM...")

    When you're making a reservation, basically what you need to ensure is that a series of SQL operations, such as looking up values, updating the record-counts of a set of records, and so-on, will be treated as an atomic "unit of work." That's what a transaction is all about, and that's going to be the key to the problem that you have quite-correctly identified.
    ChimneySweep(R): fast, automatic
    table repair at a click of the
    mouse! http://www.sundialservices.com

  8. #8
    Join Date
    Jan 2004
    Posts
    106
    Originally posted by sundialsvcs
    This is where 'transactions' come into play. Please refer to the Access documents where they explain not only the mechanics of how to use them, but the philosophy as well. (So this isn't an "RTFM...")

    When you're making a reservation, basically what you need to ensure is that a series of SQL operations, such as looking up values, updating the record-counts of a set of records, and so-on, will be treated as an atomic "unit of work." That's what a transaction is all about, and that's going to be the key to the problem that you have quite-correctly identified.
    thanks alot, i appreciate your help!
    do you know where i can get any additional information about SQL?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •