First question here.
So a bit of background, I'm pretty new in the development field and am creating a Database-first MVC app that basically functions as a log of video games and their genres for gamers to discover new and old games based on the genres that peak their interest. This necessitates a many-to-many relationship given one game may be classified under several genres and one genre can have multiple games classified under it. As it currently stands in my SQL Database, I have three tables - Game, Genre, and a linking table. The linking table has a FK for both the GameID as well as the GenreID. To my understanding (or lack thereof) since there's a linking table and no actual FK for genre in the Game table itself, how would I be able display the multiple genres applied to each game on each individual game's info page? Is there something I'm missing that I could include in one of the tables, a possible SQL query that would help, or is there some kind of hard coding I can do in Visual Studio once I import my DB in to program the rest of the app?
My database looks like:
CREATE TABLE Game
(
GameID INT IDENTITY(1, 1) NOT NULL,
Name NVARCHAR(50) NOT NULL,
GameDescription NVARCHAR(200) NULL
)
CREATE TABLE Genre
(
GenreID INT IDENTITY(1, 1) NOT NULL,
Genre NVARCHAR(20) NOT NULL
)
CREATE TABLE GameGenre
(
GameGenreID INT IDENTITY(1, 1) NOT NULL,
FOREIGN KEY ('GameID') REFERENCES Cities('GameID'),
FOREIGN KEY ('GenreID') REFERENCES Cities('GenreID')
)
Thank you in advance. Any and all advice is greatly appreciated!