Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions indexes/indexCreation.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Foreign Key Indexes on BookID and BorrowerID:
-- These indexes improve join performance with the Books and Borrowers tables.
CREATE INDEX idx_loans_bookid ON Loans(BookID);
CREATE INDEX idx_loans_borrowerid ON Loans(BorrowerID);
-- Index on Date Borrowed and Date Returned: Useful for queries sorting or filtering by these dates.
CREATE INDEX idx_loans_dateborrowed ON Loans(DateBorrowed);
CREATE INDEX idx_loans_datereturned ON Loans(DateReturned);
Comment on lines +6 to +7
Copy link
Collaborator

@R-abodyak R-abodyak Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me , if you have queries that use both DateBorrowed,DateReturned
you may want to create Multicolumn indexes
As MySQL will only ever use one index per table per query.

-- Index on Email: Improves performance for checking the existence of an email during new borrower registration.
CREATE INDEX idx_borrowers_email ON Borrowers(Email);