Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Plugin: Added SQL Server compability; Added FK and PK compability for MySQL and SQL Server #233

Closed
wants to merge 30 commits into from

Conversation

brunomartinspro
Copy link

No description provided.

sql server version
Sql server tweeks
sql server final tweek (sure right)
Added table count
String space
Count tables for normal sql
Removed empty spaces
Initial Foreign Key implementation
Added RowCell to scope
Added Models
Refactored TableModel usage
Created More models, refactor
Parse ForeignKey for MySQL and SQLSERVER
Separated Table Creation in UI from SQL Parse
Created Function to create Tables in UI
Added scalable tables that expand with the properties and table name
missing drawing the connector
Added SQL Server compability; Added FK and PK compability for MySQL and SQL Server
@brunomartinspro brunomartinspro changed the title Added SQL Server compability; Added FK and PK compability for MySQL and SQL Server SQL Plugin: Added SQL Server compability; Added FK and PK compability for MySQL and SQL Server Mar 13, 2018
@jgraph jgraph deleted a comment from brunomartinspro Mar 15, 2018
@jgraph jgraph deleted a comment from TCB13 Mar 15, 2018
@brunomartinspro
Copy link
Author

brunomartinspro commented Mar 15, 2018

@davidjgraph @christ66 @alderg Can i humbly ask for feedback about why my comment was deleted and when can this go to production? Thank you
Stackoverflow Question i made for this feature and how it can be tested: https://stackoverflow.com/questions/49198853/foreign-key-on-sql-plugin

@alderg
Copy link
Contributor

alderg commented Mar 16, 2018

Thanks for the PR, this will be merged via our main repo and will appear in the next release.

@alderg alderg closed this Mar 16, 2018
@alderg
Copy link
Contributor

alderg commented Apr 19, 2018

The plugin is available via Arrange, Insert, From SQL using this link.

@Eddie-Hartman
Copy link

@brunomartinspro Did this functionality break? Your examples in the SO post do not create linkages between the tables as foreign keys.
Example:
image

@brunomartinspro
Copy link
Author

brunomartinspro commented Aug 20, 2020

@brunomartinspro Did this functionality break? Your examples in the SO post do not create linkages between the tables as foreign keys.
Example:
image

Unfortunately i never figured out how to visually link the foreign keys in 2018.
The rest remained the same as it was before, even with SQL it didn't linked the boxes to the properties.

Script generated from SSMS:

USE [test]
GO
/****** Object:  Table [dbo].[Rocket]    Script Date: 20/08/2020 10:44:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Rocket](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[StatusId] [int] NOT NULL,
 CONSTRAINT [PK_Rocket] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[RocketStatus]    Script Date: 20/08/2020 10:44:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[RocketStatus](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nchar](30) NOT NULL,
 CONSTRAINT [PK_RocketStatus] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Rocket]  WITH CHECK ADD  CONSTRAINT [FK_Rocket_RocketStatus] FOREIGN KEY([StatusId])
REFERENCES [dbo].[RocketStatus] ([Id])
GO
ALTER TABLE [dbo].[Rocket] CHECK CONSTRAINT [FK_Rocket_RocketStatus]
GO

image

image

MySql example copied from Draw.IO: Foreign Key on SQL Plugin :

image

image

@gaurakshay
Copy link

gaurakshay commented Aug 26, 2020

The following functionalities are not working for me:

  1. Identification of the table name.
  2. Identification of the foreign or primary key

I have identified that the reason for the table name not populating is that there should be a space between the table name and the starting parenthesis. I don't know why the foreign key and primary key identification is not working.

The result that I get if I use (taken from here ):

CREATE TABLE Persons(
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);

CREATE TABLE Orders(
    OrderID int NOT NULL,
    OrderNumber int NOT NULL,
    PersonID int,
    PRIMARY KEY (OrderID),
    FOREIGN KEY (OrderID) REFERENCES Persons(PersonID)
);

Annotation 2020-08-26 151431

@bolehlav
Copy link

Same here, Example used there doesn't work for me either.

@brunomartinspro
Copy link
Author

@Eddie-Hartman @bolehlav Well something changed... now we have to add the plugin first before we can use it...
Did you see the same UI look as the last picture?

Annotation 2020-09-10 193342
Annotation 2020-09-10 193401
Annotation 2020-09-10 193414
Annotation 2020-09-10 193440
Annotation 2020-09-10 193544

@Eddie-Hartman
Copy link

@brunomartinspro I do not have to add it first. I can just go to:

  1. Arrange
  2. Insert
  3. Advanced
  4. SQL

Your version is still there if you add the plugin first, I had assumed that the two were based off of the same code though.
They do look different in the UI on creation and the end result though.

@lastlink
Copy link

lastlink commented Oct 11, 2022

Good news is that I have a pr with improved sql parsing and working foreign relationship lines. See the new pr #3091

sql import fk preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants