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 8225217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:20:35+00:00 2026-06-07T15:20:35+00:00

I am wanting to create a sqlDB on my server, I am very new

  • 0

I am wanting to create a sqlDB on my server, I am very new to db development and have only done the odd bit of coding here an there several years ago. I am trying to build a db that has four tables that reference each other..

This is what each of the tables are created for to give you a better idea as to what I am trying to achieve.

Group
this table will store hubs which users create for other users to follow.

User
stores users details which are used when creating groups and joining groups

//Not sure if this next one is a good idea but hopefully someone can let me know what they thing about it
userGroups
this table stores all or the groups and user connections. When a user joins a group their id is stored with the group id.

Countries
countries are used to help restrict the number of results that can be returned

heres the code I have created that I would like to run on my DB.. I am not sure if I have made the foreign keys correctly, any advice on that would be appreciated also.

CREATE DATABASE tempDB
USE tempDB

CREATE TABLE Group (groupID UInt32 PRIMARY KEY, userID UInt32 references User(SID), country VARCHAR(20) references Country(SID));

CREATE TABLE User (userID UInt32 PRIMARY KEY, name VARCHAR(20), country VARCHAR(20) references Country(SID));

CREATE TABLE userGroups (userID references User(SID), groupID UInt32 references Group(SID));

CREATE TABLE countries (countryName VARCHAR(20) PRIMARY KEY);

so three questions:

  1. Is the table UserGroups worth while?
  2. Have I created the foreign Keys correctly?
  3. Will this code create a DB with the 4 tables in them…
  • 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-07T15:20:37+00:00Added an answer on June 7, 2026 at 3:20 pm

    If your users can be in many groups and many users can be in a group drop the column and foreign key reference to the userid field in the group table. The usergroups table handles this many-to-many mapping.

    Your current setup would only make sense if say each group had also a single ‘owner’ user…

    Also, what DB engine are you using? Innodb or myisam… If myisam foreign keys are jest like any other index without any ability to enforce constraints, therefore not really useful to try and declare.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wanting to create a remote NuGet server. I've followed the instructions here: http://docs.nuget.org/docs/creating-packages/hosting-your-own-nuget-feeds
So I have 2 tables, invoices and invoiceitems. I am wanting to create a
Wanting to create custom data annotation validation. Are there any useful guides / samples
I'm wanting to create a shoutbox, though I'm wondering if there is another way
I have a client who is wanting to create a link which contains product
This is a very simple question. I often find myself wanting to create a
I m setting up SVN on my local web development server and I'm wanting
I am wanting to create a Spinner from an ArrayList of Objects I have
I am wanting to create a program that talks with a Cometd server to
I am wanting to create an application in winforms that calls a new WCF

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.