GithubHelp home page GithubHelp logo

Comments (13)

luckcolors avatar luckcolors commented on July 18, 2024

Additional info on KEY index: see.

from erd-editor.

dineug avatar dineug commented on July 18, 2024

vcode extension v0.9.7 has been reflected.

from erd-editor.

luckcolors avatar luckcolors commented on July 18, 2024

Seems to be partially fixed both indexes are not present as keys in the table, but only the "KEY" index is added to the indexes of the table. The unique index is missing.

Try to run my example SQL.

from erd-editor.

dineug avatar dineug commented on July 18, 2024

Automatically generated indexes are not explicitly managed as index data.

from erd-editor.

luckcolors avatar luckcolors commented on July 18, 2024

Okay but an UNIQUE index isn't automatically generated or rather the user still needs to add it.
So i would say since you're saving for every entity the indices it has, this index is then lost on import.

from erd-editor.

dineug avatar dineug commented on July 18, 2024

Are you looking for these?
스크린샷 2021-09-09 오전 2 57 56

from erd-editor.

luckcolors avatar luckcolors commented on July 18, 2024

Nono that's not what i mean.
I'm saying that on the Database->Indexes page only the name index is listed, the unique email index is not there.

immagine

from erd-editor.

luckcolors avatar luckcolors commented on July 18, 2024

Yeah, if i add the view change i can see it aswell. But it is still not present in the table properties tab.

from erd-editor.

dineug avatar dineug commented on July 18, 2024

Doesn't UNIQUE KEY generate indexes automatically?

from erd-editor.

luckcolors avatar luckcolors commented on July 18, 2024

It does, but i think it makes sense for it to be in the list of indexes.
Also it wether a key is unique or not is not taken into account in the generated SQL atm it seems.

immagine

I personally think all indexes should be listed in the table properties indexes section of the app, it can be confusing to the user to see some indexes only when you change the app view.

Honestly i doesn't really matter where you define the indexes: wether it be immediately in the CREATE TABLE statement or in a following CREATE INDEX statement.

from erd-editor.

dineug avatar dineug commented on July 18, 2024

I checked that it was missing from the simple table SQL DDL.

스크린샷 2021-09-09 오전 3 36 14

PRIMARY KEY, UNIQUE KEY can't be edited.
I think it needs to be done in a way that only shows the list.

from erd-editor.

luckcolors avatar luckcolors commented on July 18, 2024

Okay no, I wasn't talking about the Primary key. That's fine the way it is.

I'm talking about the custom UNIQUE index i'm creating on email.

According to this
You can actually add the unique index just fine later with the CREATE INDEX statement (it automatically does the alter table for you).

I think i understand what you where saying earlier.
I suppose it's up to you wether you want to list all indexes in the Table Properties Indexes.
I don't think it's going to be problematic, might even be more user friendly, you could aswell list the primary key index there aswell.

Now how you actually generate the table could change based on how every index is defined:

  • The PRIMARY INDEX ofcourse needs to happend in the CREATE TABLE.

  • UNIQUE index with only 1 key can be rapresented with the UNIQUE keyword in the table definition query.

  • Other more complex index could be added either as a KEY statement or with extra CREATE INDEX statements.

Again i don't think it matters that much as all of the SQL it is generating is going to be used to create a DATABASE from scratch.
I just think it can be confusing not listing just UNIQUE immediate indexes in the Table Properties, as you will only be able to see them by changing the table view.

from erd-editor.

luckcolors avatar luckcolors commented on July 18, 2024

For example the SQL query i was tesing with can be rapresented as:

CREATE TABLE 'users' (
  'id' bigint unsigned NOT NULL AUTO_INCREMENT,
  'name' varchar(30) NOT NULL,
  'email' varchar(30) NOT NULL UNIQUE,
  PRIMARY KEY ('id'),
  KEY 'user_name_index' ('name')
);

Of course with multi key indexes you need to use the KEY statement.

Or as:

CREATE TABLE 'users' (
  'id' bigint unsigned NOT NULL AUTO_INCREMENT,
  'name' varchar(30) NOT NULL,
  'email' varchar(30) NOT NULL,
  PRIMARY KEY ('id'),
);

CREATE UNIQUE INDEX users_email_index
ON users(email ASC);

CREATE INDEX users_name_index
ON users(name ASC);

from erd-editor.

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.