U
U
user.2018-11-12 22:31:34
MySQL
user., 2018-11-12 22:31:34

Are all connections correct in this uml diagram?

Hello,
Recently I already asked a question about the database on this resource, and received good answers. Actually, the second time has come :)
I’ll say right away that I didn’t make the UML diagram, it came to me in this form, you need to implement the database (mysql) based on it, the fact is that either there are serious errors in it or I just can’t do it right understand.
1. I can’t understand how the user’s belonging to a group will be determined (there should be one more field in the user table ...)
2. The Port table (I can’t understand why the author made it red), we will also pick up fields with id in it
Does it make sense to merge some tables? Since the query syntax seems to me to be not quite easy.
5be9d37499e18442234739.png
If anyone has the strength to help me, I will be extremely grateful.
The author said that 'OPEN API' will be used (maybe it's just not clear to me) I find Swagger with which I worked a little on this request, and if I understood its essence correctly, then it serves for visual interaction, so to speak (requests through the web interface) and documenting work with the REST controller. But what does it have to do with databases, I sit and can not understand.
Task:
To a project that is implemented in the java framework 'SpringBoot' and using hibernate and a class that implements CRUD which is called:
import org.springframework.data.repository.CrudRepository;
implement this database.
Task:
In a project that is implemented in the java framework 'SpringBoot' and using hibernate and a class that implements CRUD which is called:
import org.springframework.data.repository.CrudRepository;
implement this database.
If I correctly understood the principle of hibernate, then I do not have to create this database at all. It is just required to declare in my application entity classes such as (port, host cve, etc.) and already USING the annotations provided by HIBERNATE to link these tables, and then using the CrudRepository functionality (a class that implements CRUD) Create / Read and. etc. from the database (I write as I understand at this stage)
The only and most important thing that I am trying and cannot understand is how this base will be implemented? In my understanding, CLASS = TABLE, Or can I put in the base NOT specifying a TABLE, three entities HOST, PORT, CVE and already HIBERNATE will create additional tables? Keys, links between them?
Thanks in advance everyone!
Here's what I've got so far:
I repeat that I'm not sure that I'm starting to understand the database myself and I'm not sure that I correctly understood the essence of this UML diagram.

CREATE TABLE `Right` (
  `Id_right` int(12) NOT NULL AUTO_INCREMENT,
  `Descr_Right` varchar(32) NOT NULL,
  PRIMARY KEY (`id_right`)
);

CREATE TABLE `Group` (
 `Id_group` int(12) NOT NULL AUTO_INCREMENT,
 `Decsr_Group` varchar(32) NOT NULL,
  PRIMARY KEY (`id_group`)
);






CREATE TABLE `Group_Right` (
        `Id_right` integer NOT NULL,
        `Id_group` integer  NOT NULL,

        PRIMARY KEY (`Id_right`, `Id_group`),
        FOREIGN KEY (`Id_right`) REFERENCES `Right`,
        FOREIGN KEY (`Id_group`) REFERENCES `Group`
);

CREATE TABLE `Group_User` (
        `Id_group` integer NOT NULL,
        `Id_user` integer  NOT NULL,

        PRIMARY KEY (`Id_group`, `Id_user`),
        FOREIGN KEY (`Id_group`) REFERENCES Group,
        FOREIGN KEY (`Id_user`) REFERENCES User
);

CREATE TABLE `User_Job` (
        `Id_user` integer NOT NULL,
        `Id_job` integer  NOT NULL,

        PRIMARY KEY (`Id_user`, `Id_job`),
        FOREIGN KEY (`Id_user`) REFERENCES `User`,
        FOREIGN KEY (`Id_job`)  REFERENCES `Job`
);

CREATE TABLE `User_Log_Host` (
        `Id_user` integer NOT NULL,
        `Id_job` integer  NOT NULL,
        `Id_host` integer  NOT NULL,

        PRIMARY KEY (`Id_user`, `Id_job`, `Id_host`),
        FOREIGN KEY (`Id_user`)  REFERENCES `User`,
        FOREIGN KEY (`Id_job`)   REFERENCES `Job`,
        FOREIGN KEY (`Id_host`)  REFERENCES `Host`
);

CREATE TABLE `Host_Port` (
        `Id_host` integer NOT NULL,
        `Id_port`  integer  NOT NULL,

        PRIMARY KEY (`Id_host`, `Id_port`),
        FOREIGN KEY (`Id_host`)  REFERENCES `Host`,
        FOREIGN KEY (`Id_port`)   REFERENCES `Port`
);

CREATE TABLE `Cve_Port` (
        `Id_cve`   integer NOT NULL,
        `Id_port`  integer  NOT NULL,

        PRIMARY KEY (`Id_cve`, `Id_port`),
        FOREIGN KEY (`Id_cve`)  REFERENCES `Cve`,
        FOREIGN KEY (`Id_port`)   REFERENCES `Port`
);






CREATE TABLE `User` (
  `Id_user` int(12) NOT NULL AUTO_INCREMENT,
  `User` varchar(32) NOT NULL,
  `Pass` varchar(32) NOT NULL,
  PRIMARY KEY (`id_user`)
);

CREATE TABLE `Log` (
 `Id_log` int(12) NOT NULL AUTO_INCREMENT,
 `Nom_log` varchar(32) NOT NULL,
  PRIMARY KEY (`id_log`)
);

CREATE TABLE `Job` (
 `Id_job` int(12) NOT NULL AUTO_INCREMENT,
 `Job_name` varchar(32) NOT NULL,
  PRIMARY KEY (`id_job`)
);

CREATE TABLE `Host` (
 `Id_host` int(12) NOT NULL AUTO_INCREMENT,
 `Name` varchar(32) NOT NULL,
 `Os_info` varchar(32) NOT NULL,
  PRIMARY KEY (`id_host`)
);

CREATE TABLE `Port` (
  `Id_port` int(12) NOT NULL AUTO_INCREMENT,
  `Service_p` varchar(32) NOT NULL,
  `Service_v` varchar(32) NOT NULL,
  PRIMARY KEY (`id_port`)
);

CREATE TABLE `Cve` (
  `Id_cve` int(12) NOT NULL AUTO_INCREMENT,
  `Service_c` varchar(32) NOT NULL,
  `Descr_c` varchar(32) NOT NULL,
  PRIMARY KEY (`Id_cve`)
);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Therapyx, 2018-11-12
@Therapyx

the table is terrible, everywhere stupidly scattered from zero to n, there are generally a minimum of connections. The logic of spruce is visible. Even the association is not made according to the rules.
think right.
42, the port has many hosts and vice versa))
I do not rule out that I can also say blizzard, because I do not work so often with database design ... But I will subscribe and I am very interested to hear something positive about it))

V
vism, 2018-11-13
@vism

1. There are no IDs listed anywhere. This is not a database schema, but an interaction logic. So everything is fine. You already need to create a database schema.
2. Just do a port through the link table here and there and inappropriately ID.
3. What is OpenApi interesting too) But you didn’t ask him?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question