0
嗨好,我有兩個表一個名爲登錄名和一個叫做用戶有來自用戶表一一對應的關係到登錄表:的mysql數據庫中的關係問題
Login:
=-=-=-=-
LoginID (Primary, Not Null, Auto Inc)
UserID (Primary)
Username (not null)
Password (not null)
User:
=-=-=-=-
UserID (Primary)
Email
Name etc
我再也無法迴避它我的頭但我不知道什麼時候將它編碼到我的頁面上如何在與實際用戶相關的登錄表中設置UserID?
如果我將客戶端轉到創建用戶頁面並填寫用戶詳細信息,那麼我會將他轉到用戶名和密碼字段,該字段會轉到另一個表中登錄表中的UserID設置如何? Atm不是?
櫃面任何人想反向工程MySQL的EER圖我的表中的數據看下面的代碼:
SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @[email protected]@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 [email protected]_SQL_MODE;
SET [email protected]_FOREIGN_KEY_CHECKS;
SET [email protected]_UNIQUE_CHECKS;
是的,我想我將不得不有這樣做,謝謝你的確認 –