Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7978813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:35:34+00:00 2026-06-04T09:35:34+00:00

I am writing a query to create a database in SQL server 2008 R2.

  • 0

I am writing a query to create a database in SQL server 2008 R2. I plan to use it with entity framework in a mvc3 application

I have users, games and highscores.
What I want ot do is this:

I want to create a many-to-many relationship between users and games.

Each User can have multiple games and each game can have multiple users.

and each relation user-game has 1 high score.

So far I created the users, games, highscores tables:

CREATE TABLE Users
(
    UserId INT IDENTITY(1,1),
    FirstName VARCHAR(64) NOT NULL,
    LastName VARCHAR(64) NOT NULL,
    Email VARCHAR(200) NOT NULL,
    CreatedDate DateTime NULL,
    PhoneNumber VARCHAR(32) NULL,
    Password VARCHAR(64),
    CONSTRAINT pk_users_userid PRIMARY KEY(UserId)
)
CREATE TABLE Games
(
    GameId INT IDENTITY(1,1),
    Url VARCHAR(64) NOT NULL,
    CONSTRAINT pk_gamess_gameid PRIMARY KEY(GameId)
)
CREATE TABLE Highscores
(
    HighscoreId INT IDENTITY(1,1),
    Value INT NOT NULL,
    CONSTRAINT pk_surveyors_surveyorid PRIMARY KEY(HighscoreId)
)   

What is the best way to create the many-to-many user-game relation and give each relation one high score? should I create a 4th table to hold the relation? And if I do so will I be able to use the database with Entity framework in an MVC3 application or would that complicate it?

Thank you

Additional note: I am planning to use this database with entity framework in a MVC 3 web application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:35:36+00:00Added an answer on June 4, 2026 at 9:35 am
    CREATE TABLE Users (
         UserId INT IDENTITY(1,1),
         FirstName VARCHAR(64) NOT NULL,
         LastName VARCHAR(64) NOT NULL,
         Email VARCHAR(200) NOT NULL,
         CreatedDate DateTime NULL,
         PhoneNumber VARCHAR(32) NULL,
         Password VARCHAR(64),
         CONSTRAINT pk_users_userid PRIMARY KEY(UserId)
    )
    
    CREATE TABLE Games (
       GameId INT IDENTITY(1,1),
       Url VARCHAR(64) NOT NULL,
       CONSTRAINT pk_gamess_gameid PRIMARY KEY(GameId)
    )
    
    CREATE TABLE Highscores (
       HighscoreId INT IDENTITY(1,1),
       UserID Int,
       GameID Int,
       Value INT NOT NULL,
       CONSTRAINT pk_surveyors_surveyorid PRIMARY KEY(HighscoreId)
    ) 
    
    ALTER TABLE [dbo].[Highscores]  ADD  CONSTRAINT [FK_Highscores_Games] FOREIGN KEY([GameID])
    ALTER TABLE [dbo].[Highscores]  ADD  CONSTRAINT [FK_Highscores_Users] FOREIGN KEY([UserID])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server 2008 instance with several databases and I'm currently writing
I have an existing SQL Server database whose structure I can't really change, although
I have 3 home PCs that have 2008 SQL Server Express instances installed on
I'm writing a web application and i'm thinking about sql injections. I have created
I'm writing a query that inserts customer data into a MSSQL database. Very basic.
I am having trouble writing a query. I have been working with UNION on
I am writing an SQL query which involves finding if timestamp falls in particular
Writing my first SQL query to run specifically as a SQL Job and I'm
I'm writing a PHP script to generate SQL dumps from my database for version
I need a little help writing a query. I have this data... vDir iNumber

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.