mysql - SQL Management Studio - 数据库图表不显示创建的每个表

标签 mysql sql database database-diagram

所以我创建了一个看起来像这样的数据库。

CREATE TABLE Budova
(
BudovaID int primary key not null,
BytyPocet int not null,
);
CREATE TABLE Skupina
(
SkupinaID int primary key not null,
NajemniciPocet int not null,
BytID int not null,
FOREIGN KEY (BytID) REFERENCES Byt(BytID) ON DELETE CASCADE,
);
CREATE TABLE Najemnici
(
NajemnikID int primary key not null,
Jmeno varchar(255) null,
Prijmeni varchar(255) null, 
Vek int null,
SkupinaID int not null,
BytID int not null,
CenaEnergii int not null,
FOREIGN KEY (BytID) REFERENCES Byt(BytID),
FOREIGN KEY (SkupinaID) REFERENCES Skupina(SkupinaID) 
);
CREATE TABLE Byt
(
BytID int primary key not null,
BudovaID int not null,
OpravaID int not null,
FOREIGN KEY (BudovaID) REFERENCES Budova(BudovaID) ON DELETE CASCADE,
FOREIGN KEY (OpravaID) REFERENCES Opravy(OpravaID) ON DELETE CASCADE

);
CREATE TABLE Vydaje
(
BytID int not null,
Voda int not null,
Elektrina int not null,
Plyn int not null,
Zaloha int not null,
Celkem int not null,
CelkemEura int not null
FOREIGN KEY (BytID) REFERENCES Byt(BytID)
);
CREATE TABLE Opravy 
(
OpravaID int primary key not null,
OpravaTyp varchar(255) not null,
OpravaCena int not null,
);

我的数据库中基本上有 6 个表,但是当我尝试创建数据库图表时,它并没有显示每个表。 As you can see, it shows only 5 of them.

At the end, it looks like that.

我尝试过更改引用,但结果简直就是 hell 。你知道我应该做什么才能让它发挥作用吗?

最佳答案

无论您使用哪种数据库管理系统,您的语句中都有很多错误。

尝试按照发布的顺序创建查询,否则外键将不起作用

CREATE TABLE Budova
(
BudovaID int primary key not null,
BytyPocet int not null
);
CREATE TABLE Opravy 
(
OpravaID int primary key not null,
OpravaTyp varchar(255) not null,
OpravaCena int not null
);
CREATE TABLE Byt
(
BytID int primary key not null,
BudovaID int not null,
OpravaID int not null,
FOREIGN KEY (BudovaID) REFERENCES Budova(BudovaID) ON DELETE CASCADE,
FOREIGN KEY (OpravaID) REFERENCES Opravy(OpravaID) ON DELETE CASCADE

);
CREATE TABLE Skupina
(
SkupinaID int primary key not null,
NajemniciPocet int not null,
BytID int not null,
FOREIGN KEY (BytID) REFERENCES Byt(BytID) ON DELETE CASCADE
);

CREATE TABLE Najemnici
(
NajemnikID int primary key not null,
Jmeno varchar(255) null,
Prijmeni varchar(255) null, 
Vek int null,
SkupinaID int not null,
BytID int not null,
CenaEnergii int not null,
FOREIGN KEY (BytID) REFERENCES Byt(BytID),
FOREIGN KEY (SkupinaID) REFERENCES Skupina(SkupinaID) 
);



CREATE TABLE Vydaje
(
BytID int not null,
Voda int not null,
Elektrina int not null,
Plyn int not null,
Zaloha int not null,
Celkem int not null,
CelkemEura int not null,
FOREIGN KEY (BytID) REFERENCES Byt(BytID)
);

关于mysql - SQL Management Studio - 数据库图表不显示创建的每个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59918781/

相关文章:

php - 使用 Zend_Db_Table_Abstract::insert() 延迟插入

c# - Entity Framework 查询中的自定义函数有时可以正确翻译,有时则不能

mysql - 具有多列子查询的SQL笛卡尔积,未知列问题

sql - 如何仅用一列选择多列分组依据

php - 如何阻止 MySQL 十进制字段被四舍五入?

database - 是否应删除租户?历史报告呢?

javascript - 在 Sequelize 中查找与来自其他模型的多个(所有)实例关联的实例

mysql - 对于存在多个 WHERE 的多个 COLUMNS 的 SUM,MySQL 语法是否正确?

php - 如果数据库连接失败,我如何告诉 PHP 暂停一秒钟并重试?

mysql - 将 MySQL 函数转换为 Oracle PL/SQL