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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:45:01+00:00 2026-05-20T15:45:01+00:00

Hi ok I have two tables one called Login and one called User there

  • 0

Hi ok I have two tables one called Login and one called User there is a one to one relationship from the user table to the login table:

Login:
=-=-=-=-
LoginID (Primary, Not Null, Auto Inc)
UserID (Primary)
Username (not null)
Password (not null)

User:
=-=-=-=-
UserID (Primary)
Email
Name etc

I cant get my head around it but I dont know when it comes to coding it on my page how the UserID is set in the Login table related to the actual user?

If I take the client to the create user page and he fills in the user details then I forward him to the username and password fields which goes to a different table how is the UserID set in the Login Table? Atm its not?

Incase any one wants to reverse engineer my table data in mysql eer diagram see code below:

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';

CREATE SCHEMA IF NOT EXISTS `gymwebsite` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;

USE `gymwebsite` ;
-- -----------------------------------------------------

-- Table `gymwebsite`.`User`

-- -----------------------------------------------------

CREATE  TABLE IF NOT EXISTS `gymwebsite`.`User` (
  `UserID` INT NOT NULL AUTO_INCREMENT ,
  `Email` VARCHAR(245) NULL ,
  `FirstName` VARCHAR(45) NULL ,    
  `SecondName` VARCHAR(45) NULL ,    
  `DOB` VARCHAR(15) NULL ,    
  `Location` VARCHAR(45) NULL ,    
  `Aboutme` VARCHAR(245) NULL ,    
  PRIMARY KEY (`UserID`) )   
ENGINE = InnoDB;

-- -----------------------------------------------------

-- Table `gymwebsite`.`Pictures`

-- -----------------------------------------------------

CREATE  TABLE IF NOT EXISTS `gymwebsite`.`Pictures` (
  `PictureID` INT NOT NULL AUTO_INCREMENT ,
  `UserID` INT NOT NULL ,
  PRIMARY KEY (`PictureID`, `UserID`) ,
  INDEX `fk_Pictures_Userinfo1` (`UserID` ASC) ,
  CONSTRAINT `fk_Pictures_Userinfo1`
    FOREIGN KEY (`UserID` )
    REFERENCES `gymwebsite`.`User` (`UserID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------

-- Table `gymwebsite`.`WallPostings`

-- -----------------------------------------------------

CREATE  TABLE IF NOT EXISTS `gymwebsite`.`WallPostings` (
  `UserwallID` INT NOT NULL AUTO_INCREMENT ,
  `UserID` INT NOT NULL ,
  PRIMARY KEY (`UserwallID`, `UserID`) ,
  INDEX `fk_WallPostings_Userinfo1` (`UserID` ASC) ,
  CONSTRAINT `fk_WallPostings_Userinfo1`
    FOREIGN KEY (`UserID` )
    REFERENCES `gymwebsite`.`User` (`UserID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------

-- Table `gymwebsite`.`Login`

-- -----------------------------------------------------

CREATE  TABLE IF NOT EXISTS `gymwebsite`.`Login` (
  `LoginID` INT NOT NULL AUTO_INCREMENT ,
  `UserID` INT NOT NULL ,
  `username` VARCHAR(245) NOT NULL ,
  `password` VARCHAR(45) NOT NULL ,
  PRIMARY KEY (`LoginID`, `UserID`) ,
  INDEX `fk_Login_Userinfo` (`UserID` ASC) ,
  CONSTRAINT `fk_Login_Userinfo`
    FOREIGN KEY (`UserID` )
    REFERENCES `gymwebsite`.`User` (`UserID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------

-- Table `gymwebsite`.`DietPlan`

-- -----------------------------------------------------

CREATE  TABLE IF NOT EXISTS `gymwebsite`.`DietPlan` (
  `DietPlanID` INT NOT NULL AUTO_INCREMENT ,
  `UserID` INT NOT NULL ,
  PRIMARY KEY (`DietPlanID`, `UserID`) ,
  INDEX `fk_DietPlan_Userinfo1` (`UserID` ASC) ,
  CONSTRAINT `fk_DietPlan_Userinfo1`
    FOREIGN KEY (`UserID` )
    REFERENCES `gymwebsite`.`User` (`UserID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

-- -----------------------------------------------------

-- Table `gymwebsite`.`WorkoutPlan`

-- -----------------------------------------------------

CREATE  TABLE IF NOT EXISTS `gymwebsite`.`WorkoutPlan` (

  `WorkOutID` INT NOT NULL AUTO_INCREMENT ,

  `UserID` INT NOT NULL ,

  PRIMARY KEY (`WorkOutID`, `UserID`) ,

  INDEX `fk_WorkoutPlan_Userinfo1` (`UserID` ASC) ,

  CONSTRAINT `fk_WorkoutPlan_Userinfo1`

    FOREIGN KEY (`UserID` )

    REFERENCES `gymwebsite`.`User` (`UserID` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;





-- -----------------------------------------------------

-- Table `gymwebsite`.`Friends`

-- -----------------------------------------------------

CREATE  TABLE IF NOT EXISTS `gymwebsite`.`Friends` (

  `idFriends` INT NOT NULL AUTO_INCREMENT ,

  `UserID` INT NOT NULL ,

  PRIMARY KEY (`idFriends`, `UserID`) ,

  INDEX `fk_Friends_Userinfo1` (`UserID` ASC) ,

  CONSTRAINT `fk_Friends_Userinfo1`

    FOREIGN KEY (`UserID` )

    REFERENCES `gymwebsite`.`User` (`UserID` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;







SET SQL_MODE=@OLD_SQL_MODE;

SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;

SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  • 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-05-20T15:45:01+00:00Added an answer on May 20, 2026 at 3:45 pm

    If User and Login has a 1:1 relation, you should drop LoginID from the Login table, and make UserID the primary key instead.
    Or, if all users have login-information, you may consider moving the columns into the User table instead. (By doing so you also remove an entire class of problems related to enforcing 1-1 relations).

    You should not insert any rows in the database until the user completes the entire registration form. Keep the form data in the session, and then at the end perform all inserts in all tables at once, then commit.

    There is probably a function in c# to find out the last inserted id (UserID) to put in the Login table, otherwise have a look at the MySQL documentation for insert ID

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

Sidebar

Related Questions

No related questions found

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.