我想知道我的数据库是否符合数据库规范化 (3NF/BCNF)。我也想知道我是否应该将“accoundID”与用户 ID 分开。
Create table IF NOT exists Users(
UserID int primary key auto_increment,
Firstname varchar (200),
Lastname varchar (200),
telnumber int not null,
age int not null,
accountID int,
FOREIGN KEY (accountID) REFERENCES accounts(accountID)
);
Create table IF NOT exists accounts (
accountID int primary key auto_increment,
Username varchar(200),
Password varchar(200),
RegistrationDate DATETIME DEFAULT current_timestamp,
Email varchar(200),
image_type VARCHAR(255),
image_data LONGBLOB,
Secretqt varchar (200),
Secretans varchar (200)
);
Create table if not exists posts (
PostId int primary key auto_increment,
AccountID int,
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
CategoriID int,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (AccountID) references accounts(accountID),
FOREIGN KEY (CategoriID) REFERENCES categroies(CategoriID)
);
Create table if not exists categroies(
CategoriID int primary key auto_increment,
Categoriname varchar(200),
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp
);
我自己做了一项研究,得出的结论是这是我能做的最好的。但我也认为我应该有一张秘密答案表,但仅此而已。如果你有更多的想法,我会很高兴。