wise-coders / dbschema

DbSchema Database Designer
https://dbschema.com
67 stars 3 forks source link

Feature: Manage and assign filegroups to tables (Physical Model - SqlServer) #90

Closed Daniel-Pavic closed 1 year ago

Daniel-Pavic commented 1 year ago

Dear dbschema-Team,

we recently purchased the Pro Edition of dbschema. After working for more than a decade with different ERD-Tools I might be a bit spoiled - but the pro version lacks (IMHO) of quite some relevant features (if I did not miss something):

One of the most "severe" one - performancewise - is the ability to assign a table to a specific filegroup - or to assign a text-filegroup for (n)varchar(MAX)-colums using the physical modeler (SqlServer)

The only option I see is to disable the "GO"-Statement after each table creation and to put the following Append Script (Options) after each and every table within the ERD:

ON [my_filegroup] TEXTIMAGE_ON [my_filegroup_txt] GO

This isn't very handy - especially having lots of tables and the need to rename a filegroup.

Is there any other way to obtain the assignment of a table to a filegroup (which is pure physical modeling imho ;) There are also no filegroups to maintain or select within dbschema, right?

Thank you in advance for your reply! Best regards, Daniel

wise-coders commented 1 year ago

Thank you for writing about this. Here is a quick fix: Please edit in Model / Settings / Database Specific / SQL Syntax/ Table / Options to

ON ~partitionSchemeOrFileGroup~ | TEXTIMAGE_ON ~fileGroup~ | FILESTREAM_ON ~partitionSchemeOrFileGroup~ | WITH ([MEMORY_OPTIMIZED=ON |DURABILITY={SCHEMA_ONLY|SCHEMA_AND_DATA} |SYSTEM_VERSIONING=ON [(HISTORY_TABLE = ~schema.table~ [, DATA_CONSISTENCY_CHECK = {ON|OFF}])] |DATA_COMPRESSION ={NONE|ROW|PAGE} [ON PARTITIONS ({~partitionNumberExpression~|~range~})] |FILETABLE_DIRECTORY=~directoryName~ |FILETABLE_COLLATE_FILENAME={~collationName~|database_default} |FILETABLE_PRIMARY_KEY_CONSTRAINT_NAME=~constraintName~ |FILETABLE_STREAMID_UNIQUE_CONSTRAINT_NAME=~constraintName~ |FILETABLE_FULLPATH_UNIQUE_CONSTRAINT_NAME=~constraintName~ |SYSTEM_VERSIONING=ON [(HISTORY_TABLE=~schemaName.historyTableName~ [, DATA_CONSISTENCY_CHECK={ON|OFF}])] |REMOTE_DATA_ARCHIVE={ ON [(~tableStretchOptions~)]|OFF ( MIGRATION_STATE=PAUSED)} |LOCATION=~locationOrPath~ |DATA_SOURCE=~externalDataSourceName~ |FILE_FORMAT=~externalFileFormatName~ |REJECT_TYPE=~value~ |REJECT_VALUE='~value~ |REJECT_SAMPLE_VALUE=~rejectSampleValue~ |REJECTED_ROW_LOCATION='~location~'])

and SQL Settings / Data Providers to:

partitionScheme.sql: SELECT name FROM sys.partition_schemes

partitionSchemeOrFileGroup.sql: SELECT name FROM sys.filegroups UNION SELECT name from sys.partition_schemes

fileGroup.sql: SELECT name FROM sys.filegroups

collationName.sql: SELECT name FROM sys.fn_helpcollations()

this one needs the empty lines between. I am not sure if the queries are really fine. The CREATE TABLE syntax is

CREATE TABLE
    { database_name.schema_name.table_name | schema_name.table_name | table_name }
    [ AS FileTable ]
    (....)
    [ ON { partition_scheme_name ( partition_column_name )
           | filegroup
           | "default" } ]
    [ TEXTIMAGE_ON { filegroup | "default" } ]
    [ FILESTREAM_ON { partition_scheme_name
           | filegroup
           | "default" } ]
    [ WITH ( <table_option> [ ,... n ] ) ]

and I don't know how to get the partion_column_name.

See this in action in the Table Dialog / Options Tab / Suffix.

Daniel-Pavic commented 1 year ago

Thank you for providing this fix! I'll try it out and let you know ASAP. Best regards, Daniel

Daniel-Pavic commented 1 year ago

Hello,

after applying the fix provided, I get the subsequent error when trying to select filegroup from the dropdown within the options dialog:

Start DbSchema. ==== 2023-01-11 10:16:27 DbSchema #221214 Windows 10 10.0 Java BellSoft 17.0.5 === Screen Size: [1936.0,1216.0] outputScaleY=1.0 screenResolution=Large Use RDBMS: SqlServer Open Project 'RayMail_SqlServer' SqlServer 6 Tables, 1 Layouts, 0 Browse, 0 SQL Editors Dialog Edit Table in Schema config

add Dialog Options Dialog Connect: SqlServer Connected.


Ab hier händisch eingetragen:

Bei Klick auf Option-Value von Option "ON ~partitionSchemeOrFileGroup~" erscheint folgender Fehler, welcher nicht im Log landet:

groovy.lang.MissingPropertyException: No such property: name for class: Script1 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:67) at org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.unwrap(IndyGuardsFiltersAndSignatures.java:161) at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:318) at Script1.run(Script1.groovy:1) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:460) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:495) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:469) at com.wisecoders.dbs.config.model.ProviderProperty.a(ProviderProperty.java:171) at com.wisecoders.dbs.config.fx.FxSyntaxOptionDialog$1.a(FxSyntaxOptionDialog.java:230) at com.wisecoders.dbs.config.fx.FxSyntaxOptionDialog$1.call(FxSyntaxOptionDialog.java:226)

Bei der DB handelt es sich um eine Microsoft SQL Server 2019 DB unter Docker/Linux auf port 1434. Der SQL-Befehl

SELECT name FROM sys.filegroups UNION SELECT name from sys.partition_schemes

funktioniert aber!

Gruß, Daniel

wise-coders commented 1 year ago

I have updated the initial SQL and added .sql after each key. For example: fileGroup -> fileGroup.sql

Daniel-Pavic commented 1 year ago

It's impossible for me to edit the Data Providers. Changes will not be updated. Once I typed some word "bka" (should be "bla") that is now undeletable - as new entry "Unknown:bka". Restore does not delete this entry. No error or specific entry in log.txt. Strange.

Daniel-Pavic commented 1 year ago

Hi, have you tried this yourself or does it only happen to me that changes to the Data Providers can not be applied? Thank you in advance for your reply. Best regards, Daniel

wise-coders commented 1 year ago

I reproduced this issue. This configuration node expects only rows using key:value. the ':' is expected. Also empty rows between records. On Monday we will release also a beta update with the fixes under https://dbschema.com/beta.php

Daniel-Pavic commented 1 year ago

Okay, very nice, thank you, looking forward! Just in case you guys are interested: I could give you a quick introduction/overview of Toad Data Modeler and what I like about this (old fashioned) product. It's quite good regarding the workflow and the few number of clicks you have perform in order to achieve modeling. Despite the fact it seems to be outdated and no longer maintained, it has some advantages over dbschema - maybe you might want to have a look at them (via Teams or whatever). Just an offer. Thank you anyways for quickly adressing my issue! Best regards, Daniel

wise-coders commented 1 year ago

Thank you very much! We greatly appreciate, and would be nice to get this introduction. We are planning to re-implement features related to logical design, and we would also use this opportunity. Is it possible to organize it right this week? Please let me know your time availability. We are on Europe Berlin time.

Daniel-Pavic commented 1 year ago

Sure, I am from Frankfurt area, Germany, so this might make things a bit easier for us :-) how can we connect best without leaving my mail or phone number here?

wise-coders commented 1 year ago

Please create a ticket using DbSchema / Help / Create Support Ticket. It will go through email.

Best regards, Dragos Pruteanu

Daniel-Pavic commented 1 year ago

Just sent and got "Ticket Created" with an Exception Stacktrace. Did you receive it?