Skip to content

Commit

Permalink
Feat: Added new table for favourites
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBalunan committed Apr 16, 2026
1 parent 0f95e96 commit 83f5135
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Binary file modified docs/SqlDatabase/ER-DiagramFile.mwb.bak
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,30 @@ FOREIGN KEY (`UUID_charity`)
ENGINE = InnoDB;
""";

String userHasFavourites =
"""
-- -----------------------------------------------------
-- Table `apbaluna`.`User_has_favourites`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `apbaluna`.`User_has_favourites` (
`Favourite_Charity` CHAR(36) NOT NULL,
`Favourer` CHAR(36) NOT NULL,
PRIMARY KEY (`Favourite_Charity`, `Favourer`),
INDEX `fk_Charities_has_User_User2_idx` (`Favourer` ASC) VISIBLE,
INDEX `fk_Charities_has_User_Charities2_idx` (`Favourite_Charity` ASC) VISIBLE,
CONSTRAINT `fk_Charities_has_User_Charities2`
FOREIGN KEY (`Favourite_Charity`)
REFERENCES `apbaluna`.`Charities` (`UUID_charities`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Charities_has_User_User2`
FOREIGN KEY (`Favourer`)
REFERENCES `apbaluna`.`User` (`UUID_User`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
""";

try (Connection conn = connection.getMySqlConnection();
Statement s = conn.createStatement()) {

Expand All @@ -280,6 +304,8 @@ FOREIGN KEY (`UUID_charity`)
s.execute(charityCategoriesTable);
s.execute(charityUserTable);
s.execute(charityVanityTable);
s.execute(userHasFavourites);

} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("Error creating table.");
Expand Down

0 comments on commit 83f5135

Please sign in to comment.