Git Product home page Git Product logo

Comments (5)

Blackdread avatar Blackdread commented on July 1, 2024

I do not understand, can you show UML/example?

from sql-to-jdl.

sheryarshirazi avatar sheryarshirazi commented on July 1, 2024

see sql tables (users, locations and user_locations) below

CREATE TABLE users (
	id int(11) NOT NULL,
	full_name VARCHAR(100) NOT NULL,
  PRIMARY KEY (id)
);

CREATE TABLE locations (
  id int(11) NOT NULL,
  street varchar(30) NOT NULL,
  city varchar(30) NOT NULL,
  state varchar(30) NOT NULL,
  PRIMARY KEY (id)
);

CREATE TABLE users_locations (
  user_id INT,
  location_id INT,
  CONSTRAINT user_add_pk PRIMARY KEY (user_id, location_id),
  CONSTRAINT FK_user FOREIGN KEY (user_id) REFERENCES users (id),
  CONSTRAINT FK_location FOREIGN KEY (location_id) REFERENCES locations (id)
);

ERD

but generated jdl as

entity Locations(locations) {
    id Integer required,
    street String required maxlength(30),
    city String required maxlength(30),
    state String required maxlength(30)
}

entity Users(users) {
    id Integer required,
    fullName String required maxlength(100),
}

// Relations

// TODO This is a pure ManyToMany relation (delete me and decide owner side)
relationship ManyToMany {
    UsersLocations{user required} to Users{usersLocations}
}

// TODO This is a pure ManyToMany relation (delete me and decide owner side)
relationship ManyToMany {
    UsersLocations{location required} to Locations{usersLocations}
}

it omits bridge table (connecting table) if table has only foreign keys. You have also mentioned in readme so my question is in this regard that can we enforce to generate this bridge table entity.
one thing if we add 3rd column in bridge table it will generate entity.

from sql-to-jdl.

Blackdread avatar Blackdread commented on July 1, 2024

As I understand, this a feature request for forcing an entity creation of UsersLocations and have 2 ManyToOne relations defined, am I correct?
I see the feature configuration could be:

  • Add boolean to specify if force all ManyToMany as 2 ManyToOne (default is false) and generate entities
  • Add list of table names to override default for specified tables to force ManyToMany as 2 ManyToOne and make those tables as entities

As you have noted, adding an extra column in users_locations will not consider that table as a ManyToMany which is correct current behaviour.

If you want to add that feature, please follow on above requirements given.

from sql-to-jdl.

sheryarshirazi avatar sheryarshirazi commented on July 1, 2024

you are right.

from sql-to-jdl.

octgsoftware avatar octgsoftware commented on July 1, 2024

I have a bit of the opposite situation in a database I am working on. There is a table with two foreign key columns, but also has an updated and created timestamp that are set with a database trigger. In this case I want it to be considered a ManyToMany, but it is treated as a separate entity. I will look into this if I get around to handling my situation.

from sql-to-jdl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.