diff --git a/sample/mssql/README.md b/sample/mssql/README.md index 5bde8483..83588f12 100644 --- a/sample/mssql/README.md +++ b/sample/mssql/README.md @@ -12,7 +12,6 @@ Sample database document. | Name | Columns | Comment | Type | Labels | | ---- | ------- | ------- | ---- | ------ | -| [Rabbits.Running](Rabbits.Running.md) | 3 | | BASIC TABLE | | | [users](users.md) | 6 | Users table | BASIC TABLE | | | [user_options](user_options.md) | 4 | User options table | BASIC TABLE | | | [posts](posts.md) | 6 | | BASIC TABLE | `green` `red` `blue` | @@ -25,6 +24,7 @@ Sample database document. | [administrator.blogs](administrator.blogs.md) | 6 | admin blogs | BASIC TABLE | | | [name with spaces](name%20with%20spaces.md) | 1 | | VIEW | | | [Sales.Product](Sales.Product.md) | 2 | | BASIC TABLE | | +| [Rabbits.Running](Rabbits.Running.md) | 3 | | BASIC TABLE | | ## Stored procedures and functions diff --git a/sample/mssql/schema.json b/sample/mssql/schema.json index 68c45d60..3730dae2 100644 --- a/sample/mssql/schema.json +++ b/sample/mssql/schema.json @@ -1 +1 @@ -{"name":"testdb","desc":"Sample database document.","tables":[{"name":"Rabbits.Running","type":"BASIC TABLE","comment":"","columns":[{"name":"LocationID","type":"int","nullable":false,"default":null,"comment":""},{"name":"ProductID","type":"int","nullable":true,"default":null,"comment":""},{"name":"EmployeeID","type":"int","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PK__Running_*","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ LocationID ]","table":"Rabbits.Running","columns":["LocationID"],"comment":""},{"name":"UQ__Running_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ EmployeeID ]","table":"Rabbits.Running","columns":["EmployeeID"],"comment":""},{"name":"UQ__Running_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ ProductID ]","table":"Rabbits.Running","columns":["ProductID"],"comment":""}],"constraints":[{"name":"PK__Running_*","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ LocationID ]","table":"Rabbits.Running","referenced_table":null,"columns":["LocationID"],"referenced_columns":null,"comment":""},{"name":"UQ__Running_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ EmployeeID ]","table":"Rabbits.Running","referenced_table":null,"columns":["EmployeeID"],"referenced_columns":null,"comment":""},{"name":"UQ__Running_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ ProductID ]","table":"Rabbits.Running","referenced_table":null,"columns":["ProductID"],"referenced_columns":null,"comment":""},{"name":"FK_TempSales_SalesReason","type":"FOREIGN KEY","def":"FOREIGN KEY(ProductID) REFERENCES Sales.Product(SalesPersonID) ON UPDATE NO_ACTION ON DELETE NO_ACTION","table":"Rabbits.Running","referenced_table":"Sales.Product","columns":["ProductID"],"referenced_columns":["SalesPersonID"],"comment":""}],"triggers":[],"def":""},{"name":"users","type":"BASIC TABLE","comment":"Users table","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"username","type":"varchar(50)","nullable":false,"default":null,"comment":""},{"name":"password","type":"varchar(50)","nullable":false,"default":null,"comment":"long long long long long long long long long long long long long long long long long long long long long description"},{"name":"email","type":"varchar(355)","nullable":false,"default":null,"comment":"ex. user@example.com"},{"name":"created","type":"date","nullable":false,"default":null,"comment":""},{"name":"updated","type":"date","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PK__users_*","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"users","columns":["id"],"comment":""},{"name":"UQ__users_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ email ]","table":"users","columns":["email"],"comment":""},{"name":"UQ__users_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ username ]","table":"users","columns":["username"],"comment":""}],"constraints":[{"name":"PK__users_*","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"users","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"UQ__users_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ email ]","table":"users","referenced_table":null,"columns":["email"],"referenced_columns":null,"comment":""},{"name":"UQ__users_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ username ]","table":"users","referenced_table":null,"columns":["username"],"referenced_columns":null,"comment":""},{"name":"CK__users__username_*","type":"CHECK","def":"CHECK(len([username])\u003e(4))","table":"users","referenced_table":null,"columns":null,"referenced_columns":null,"comment":""}],"triggers":[{"name":"update_users_updated","def":"CREATE TRIGGER update_users_updated\nON users\nAFTER UPDATE\nAS\nBEGIN\n UPDATE users SET updated = GETDATE()\n WHERE id = ( SELECT id FROM deleted)\nEND;","comment":""}],"def":""},{"name":"user_options","type":"BASIC TABLE","comment":"User options table","columns":[{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"show_email","type":"bit","nullable":false,"default":"((0))","comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""},{"name":"updated","type":"date","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PK__user_opt_*","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ user_id ]","table":"user_options","columns":["user_id"],"comment":""}],"constraints":[{"name":"PK__user_opt_*","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ user_id ]","table":"user_options","referenced_table":null,"columns":["user_id"],"referenced_columns":null,"comment":""},{"name":"user_options_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(user_id) REFERENCES users(id) ON UPDATE NO_ACTION ON DELETE CASCADE","table":"user_options","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""}],"triggers":[],"def":""},{"name":"posts","type":"BASIC TABLE","comment":"","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"title","type":"varchar(255)","nullable":false,"default":null,"comment":""},{"name":"body","type":"text","nullable":false,"default":null,"comment":"post body"},{"name":"created","type":"date","nullable":false,"default":null,"comment":""},{"name":"updated","type":"date","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"posts_id_pk","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"posts","columns":["id"],"comment":""},{"name":"UQ__posts_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ user_id, title ]","table":"posts","columns":["user_id","title"],"comment":""},{"name":"posts_user_id_idx","def":"NONCLUSTERED, [ user_id ]","table":"posts","columns":["user_id"],"comment":""}],"constraints":[{"name":"posts_id_pk","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"posts","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"UQ__posts_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ user_id, title ]","table":"posts","referenced_table":null,"columns":["user_id","title"],"referenced_columns":null,"comment":""},{"name":"posts_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(user_id) REFERENCES users(id) ON UPDATE NO_ACTION ON DELETE CASCADE","table":"posts","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""}],"triggers":[{"name":"update_posts_updated","def":"CREATE TRIGGER update_posts_updated\nON posts\nAFTER UPDATE\nAS\nBEGIN\n UPDATE users SET updated = GETDATE()\n WHERE id = ( SELECT user_id FROM deleted)\nEND;","comment":""}],"def":"","labels":[{"Name":"green","Virtual":true},{"Name":"red","Virtual":true},{"Name":"blue","Virtual":true}]},{"name":"comments","type":"BASIC TABLE","comment":"","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"post_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"comment","type":"text","nullable":false,"default":null,"comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""},{"name":"updated","type":"date","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"comments_id_pk","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"comments","columns":["id"],"comment":""},{"name":"UQ__comments_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ post_id, user_id ]","table":"comments","columns":["post_id","user_id"],"comment":""},{"name":"comments_post_id_user_id_idx","def":"NONCLUSTERED, [ post_id, user_id ]","table":"comments","columns":["post_id","user_id"],"comment":""}],"constraints":[{"name":"comments_id_pk","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"comments","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"UQ__comments_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ post_id, user_id ]","table":"comments","referenced_table":null,"columns":["post_id","user_id"],"referenced_columns":null,"comment":""},{"name":"comments_post_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(post_id) REFERENCES posts(id) ON UPDATE NO_ACTION ON DELETE NO_ACTION","table":"comments","referenced_table":"posts","columns":["post_id"],"referenced_columns":["id"],"comment":""},{"name":"comments_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(user_id) REFERENCES users(id) ON UPDATE NO_ACTION ON DELETE NO_ACTION","table":"comments","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""}],"triggers":[],"def":""},{"name":"comment_stars","type":"BASIC TABLE","comment":"","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"comment_post_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"comment_user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""},{"name":"updated","type":"date","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"UQ__comment__*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ user_id, comment_post_id, comment_user_id ]","table":"comment_stars","columns":["user_id","comment_post_id","comment_user_id"],"comment":""}],"constraints":[{"name":"UQ__comment__*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ user_id, comment_post_id, comment_user_id ]","table":"comment_stars","referenced_table":null,"columns":["user_id","comment_post_id","comment_user_id"],"referenced_columns":null,"comment":""},{"name":"comment_stars_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(comment_user_id) REFERENCES users(id) ON UPDATE NO_ACTION ON DELETE NO_ACTION","table":"comment_stars","referenced_table":"users","columns":["comment_user_id"],"referenced_columns":["id"],"comment":""},{"name":"comment_stars_user_id_post_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(comment_post_id, comment_user_id) REFERENCES comments(post_id, user_id) ON UPDATE NO_ACTION ON DELETE NO_ACTION","table":"comment_stars","referenced_table":"comments","columns":["comment_post_id","comment_user_id"],"referenced_columns":["post_id","user_id"],"comment":""}],"triggers":[],"def":""},{"name":"logs","type":"BASIC TABLE","comment":"","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"post_id","type":"int","nullable":true,"default":null,"comment":""},{"name":"comment_id","type":"int","nullable":true,"default":null,"comment":""},{"name":"comment_star_id","type":"int","nullable":true,"default":null,"comment":""},{"name":"payload","type":"text","nullable":true,"default":null,"comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""}],"indexes":[],"constraints":[],"triggers":[],"def":""},{"name":"post_comments","type":"VIEW","comment":"post and comments View table","columns":[{"name":"id","type":"int","nullable":true,"default":null,"comment":"comments.id"},{"name":"title","type":"varchar(255)","nullable":false,"default":null,"comment":"posts.title"},{"name":"post_user","type":"varchar(50)","nullable":true,"default":null,"comment":"posts.users.username"},{"name":"comment","type":"text","nullable":true,"default":null,"comment":""},{"name":"comment_user","type":"varchar(50)","nullable":true,"default":null,"comment":"comments.users.username"},{"name":"created","type":"date","nullable":true,"default":null,"comment":"comments.created"},{"name":"updated","type":"date","nullable":true,"default":null,"comment":"comments.updated"}],"indexes":[],"constraints":[],"triggers":[],"def":"CREATE VIEW post_comments AS (\n SELECT c.id, p.title, u2.username AS post_user, c.comment, u2.username AS comment_user, c.created, c.updated\n FROM posts AS p\n LEFT JOIN comments AS c on p.id = c.post_id\n LEFT JOIN users AS u on u.id = p.user_id\n LEFT JOIN users AS u2 on u2.id = c.user_id\n);","referenced_tables":["posts","comments","users"]},{"name":"CamelizeTable","type":"BASIC TABLE","comment":"","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""}],"indexes":[],"constraints":[],"triggers":[],"def":""},{"name":"hyphen-table","type":"BASIC TABLE","comment":"","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"hyphen-column","type":"text","nullable":false,"default":null,"comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""}],"indexes":[],"constraints":[],"triggers":[],"def":""},{"name":"administrator.blogs","type":"BASIC TABLE","comment":"admin blogs","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"name","type":"text","nullable":false,"default":null,"comment":""},{"name":"description","type":"text","nullable":true,"default":null,"comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""},{"name":"updated","type":"date","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PK__blogs_*","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"administrator.blogs","columns":["id"],"comment":""}],"constraints":[{"name":"PK__blogs_*","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"administrator.blogs","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"blogs_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(user_id) REFERENCES users(id) ON UPDATE NO_ACTION ON DELETE CASCADE","table":"administrator.blogs","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""}],"triggers":[],"def":""},{"name":"name with spaces","type":"VIEW","comment":"","columns":[{"name":"title","type":"varchar(255)","nullable":false,"default":null,"comment":""}],"indexes":[],"constraints":[],"triggers":[],"def":"CREATE VIEW \"name with spaces\" AS (\n SELECT TOP 1 p.title\n FROM posts AS p\n);","referenced_tables":["posts"]},{"name":"Sales.Product","type":"BASIC TABLE","comment":"","columns":[{"name":"ProductID","type":"int","nullable":false,"default":null,"comment":""},{"name":"SalesPersonID","type":"int","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PK__Product_*","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ ProductID ]","table":"Sales.Product","columns":["ProductID"],"comment":""},{"name":"UQ__Product_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ SalesPersonID ]","table":"Sales.Product","columns":["SalesPersonID"],"comment":""}],"constraints":[{"name":"PK__Product_*","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ ProductID ]","table":"Sales.Product","referenced_table":null,"columns":["ProductID"],"referenced_columns":null,"comment":""},{"name":"UQ__Product_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ SalesPersonID ]","table":"Sales.Product","referenced_table":null,"columns":["SalesPersonID"],"referenced_columns":null,"comment":""}],"triggers":[],"def":""}],"relations":[{"table":"Rabbits.Running","columns":["ProductID"],"cardinality":"Zero or one","parent_table":"Sales.Product","parent_columns":["SalesPersonID"],"parent_cardinality":"Zero or one","def":"","virtual":false},{"table":"user_options","columns":["user_id"],"cardinality":"Zero or one","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"posts","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"comments","columns":["post_id"],"cardinality":"Zero or more","parent_table":"posts","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"comments","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"comment_stars","columns":["comment_user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"comment_stars","columns":["comment_post_id","comment_user_id"],"cardinality":"Zero or more","parent_table":"comments","parent_columns":["post_id","user_id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"administrator.blogs","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"logs","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"logs-\u003eusers","virtual":true},{"table":"logs","columns":["post_id"],"cardinality":"Zero or more","parent_table":"posts","parent_columns":["id"],"parent_cardinality":"Zero or one","def":"Additional Relation","virtual":true},{"table":"logs","columns":["comment_id"],"cardinality":"Zero or more","parent_table":"comments","parent_columns":["id"],"parent_cardinality":"Zero or one","def":"Additional Relation","virtual":true},{"table":"logs","columns":["comment_star_id"],"cardinality":"Zero or more","parent_table":"comment_stars","parent_columns":["id"],"parent_cardinality":"Zero or one","def":"Additional Relation","virtual":true}],"functions":[{"name":"dbo.get_user","return_type":"","arguments":"@userid int","type":"SQL inline table-valued function"},{"name":"dbo.What_DB_is_that","return_type":"","arguments":"@ID int","type":"SQL Stored Procedure"}],"driver":{"name":"sqlserver","database_version":"Microsoft SQL Server 2017 (RTM-CU31-GDR) (KB5029376) - 14.0.3465.1 (X64) \n\tJul 30 2023 15:31:58 \n\tCopyright (C) 2017 Microsoft Corporation\n\tDeveloper Edition (64-bit) on Linux (Ubuntu 18.04.6 LTS)","meta":{"dict":{"Functions":"Stored procedures and functions"}}},"labels":[{"Name":"sample","Virtual":true},{"Name":"tbls","Virtual":true}]} +{"name":"testdb","desc":"Sample database document.","tables":[{"name":"users","type":"BASIC TABLE","comment":"Users table","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"username","type":"varchar(50)","nullable":false,"default":null,"comment":""},{"name":"password","type":"varchar(50)","nullable":false,"default":null,"comment":"long long long long long long long long long long long long long long long long long long long long long description"},{"name":"email","type":"varchar(355)","nullable":false,"default":null,"comment":"ex. user@example.com"},{"name":"created","type":"date","nullable":false,"default":null,"comment":""},{"name":"updated","type":"date","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PK__users_*","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"users","columns":["id"],"comment":""},{"name":"UQ__users_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ email ]","table":"users","columns":["email"],"comment":""},{"name":"UQ__users_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ username ]","table":"users","columns":["username"],"comment":""}],"constraints":[{"name":"PK__users_*","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"users","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"UQ__users_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ email ]","table":"users","referenced_table":null,"columns":["email"],"referenced_columns":null,"comment":""},{"name":"UQ__users_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ username ]","table":"users","referenced_table":null,"columns":["username"],"referenced_columns":null,"comment":""},{"name":"CK__users__username_*","type":"CHECK","def":"CHECK(len([username])\u003e(4))","table":"users","referenced_table":null,"columns":null,"referenced_columns":null,"comment":""}],"triggers":[{"name":"update_users_updated","def":"CREATE TRIGGER update_users_updated\nON users\nAFTER UPDATE\nAS\nBEGIN\n UPDATE users SET updated = GETDATE()\n WHERE id = ( SELECT id FROM deleted)\nEND;","comment":""}],"def":""},{"name":"user_options","type":"BASIC TABLE","comment":"User options table","columns":[{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"show_email","type":"bit","nullable":false,"default":"((0))","comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""},{"name":"updated","type":"date","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PK__user_opt_*","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ user_id ]","table":"user_options","columns":["user_id"],"comment":""}],"constraints":[{"name":"PK__user_opt_*","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ user_id ]","table":"user_options","referenced_table":null,"columns":["user_id"],"referenced_columns":null,"comment":""},{"name":"user_options_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(user_id) REFERENCES users(id) ON UPDATE NO_ACTION ON DELETE CASCADE","table":"user_options","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""}],"triggers":[],"def":""},{"name":"posts","type":"BASIC TABLE","comment":"","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"title","type":"varchar(255)","nullable":false,"default":null,"comment":""},{"name":"body","type":"text","nullable":false,"default":null,"comment":"post body"},{"name":"created","type":"date","nullable":false,"default":null,"comment":""},{"name":"updated","type":"date","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"posts_id_pk","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"posts","columns":["id"],"comment":""},{"name":"UQ__posts_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ user_id, title ]","table":"posts","columns":["user_id","title"],"comment":""},{"name":"posts_user_id_idx","def":"NONCLUSTERED, [ user_id ]","table":"posts","columns":["user_id"],"comment":""}],"constraints":[{"name":"posts_id_pk","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"posts","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"UQ__posts_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ user_id, title ]","table":"posts","referenced_table":null,"columns":["user_id","title"],"referenced_columns":null,"comment":""},{"name":"posts_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(user_id) REFERENCES users(id) ON UPDATE NO_ACTION ON DELETE CASCADE","table":"posts","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""}],"triggers":[{"name":"update_posts_updated","def":"CREATE TRIGGER update_posts_updated\nON posts\nAFTER UPDATE\nAS\nBEGIN\n UPDATE users SET updated = GETDATE()\n WHERE id = ( SELECT user_id FROM deleted)\nEND;","comment":""}],"def":"","labels":[{"Name":"green","Virtual":true},{"Name":"red","Virtual":true},{"Name":"blue","Virtual":true}]},{"name":"comments","type":"BASIC TABLE","comment":"","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"post_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"comment","type":"text","nullable":false,"default":null,"comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""},{"name":"updated","type":"date","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"comments_id_pk","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"comments","columns":["id"],"comment":""},{"name":"UQ__comments_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ post_id, user_id ]","table":"comments","columns":["post_id","user_id"],"comment":""},{"name":"comments_post_id_user_id_idx","def":"NONCLUSTERED, [ post_id, user_id ]","table":"comments","columns":["post_id","user_id"],"comment":""}],"constraints":[{"name":"comments_id_pk","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"comments","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"UQ__comments_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ post_id, user_id ]","table":"comments","referenced_table":null,"columns":["post_id","user_id"],"referenced_columns":null,"comment":""},{"name":"comments_post_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(post_id) REFERENCES posts(id) ON UPDATE NO_ACTION ON DELETE NO_ACTION","table":"comments","referenced_table":"posts","columns":["post_id"],"referenced_columns":["id"],"comment":""},{"name":"comments_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(user_id) REFERENCES users(id) ON UPDATE NO_ACTION ON DELETE NO_ACTION","table":"comments","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""}],"triggers":[],"def":""},{"name":"comment_stars","type":"BASIC TABLE","comment":"","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"comment_post_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"comment_user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""},{"name":"updated","type":"date","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"UQ__comment__*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ user_id, comment_post_id, comment_user_id ]","table":"comment_stars","columns":["user_id","comment_post_id","comment_user_id"],"comment":""}],"constraints":[{"name":"UQ__comment__*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ user_id, comment_post_id, comment_user_id ]","table":"comment_stars","referenced_table":null,"columns":["user_id","comment_post_id","comment_user_id"],"referenced_columns":null,"comment":""},{"name":"comment_stars_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(comment_user_id) REFERENCES users(id) ON UPDATE NO_ACTION ON DELETE NO_ACTION","table":"comment_stars","referenced_table":"users","columns":["comment_user_id"],"referenced_columns":["id"],"comment":""},{"name":"comment_stars_user_id_post_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(comment_post_id, comment_user_id) REFERENCES comments(post_id, user_id) ON UPDATE NO_ACTION ON DELETE NO_ACTION","table":"comment_stars","referenced_table":"comments","columns":["comment_post_id","comment_user_id"],"referenced_columns":["post_id","user_id"],"comment":""}],"triggers":[],"def":""},{"name":"logs","type":"BASIC TABLE","comment":"","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"post_id","type":"int","nullable":true,"default":null,"comment":""},{"name":"comment_id","type":"int","nullable":true,"default":null,"comment":""},{"name":"comment_star_id","type":"int","nullable":true,"default":null,"comment":""},{"name":"payload","type":"text","nullable":true,"default":null,"comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""}],"indexes":[],"constraints":[],"triggers":[],"def":""},{"name":"post_comments","type":"VIEW","comment":"post and comments View table","columns":[{"name":"id","type":"int","nullable":true,"default":null,"comment":"comments.id"},{"name":"title","type":"varchar(255)","nullable":false,"default":null,"comment":"posts.title"},{"name":"post_user","type":"varchar(50)","nullable":true,"default":null,"comment":"posts.users.username"},{"name":"comment","type":"text","nullable":true,"default":null,"comment":""},{"name":"comment_user","type":"varchar(50)","nullable":true,"default":null,"comment":"comments.users.username"},{"name":"created","type":"date","nullable":true,"default":null,"comment":"comments.created"},{"name":"updated","type":"date","nullable":true,"default":null,"comment":"comments.updated"}],"indexes":[],"constraints":[],"triggers":[],"def":"CREATE VIEW post_comments AS (\n SELECT c.id, p.title, u2.username AS post_user, c.comment, u2.username AS comment_user, c.created, c.updated\n FROM posts AS p\n LEFT JOIN comments AS c on p.id = c.post_id\n LEFT JOIN users AS u on u.id = p.user_id\n LEFT JOIN users AS u2 on u2.id = c.user_id\n);","referenced_tables":["posts","comments","users"]},{"name":"CamelizeTable","type":"BASIC TABLE","comment":"","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""}],"indexes":[],"constraints":[],"triggers":[],"def":""},{"name":"hyphen-table","type":"BASIC TABLE","comment":"","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"hyphen-column","type":"text","nullable":false,"default":null,"comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""}],"indexes":[],"constraints":[],"triggers":[],"def":""},{"name":"administrator.blogs","type":"BASIC TABLE","comment":"admin blogs","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":""},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"name","type":"text","nullable":false,"default":null,"comment":""},{"name":"description","type":"text","nullable":true,"default":null,"comment":""},{"name":"created","type":"date","nullable":false,"default":null,"comment":""},{"name":"updated","type":"date","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PK__blogs_*","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"administrator.blogs","columns":["id"],"comment":""}],"constraints":[{"name":"PK__blogs_*","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ id ]","table":"administrator.blogs","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"blogs_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY(user_id) REFERENCES users(id) ON UPDATE NO_ACTION ON DELETE CASCADE","table":"administrator.blogs","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""}],"triggers":[],"def":""},{"name":"name with spaces","type":"VIEW","comment":"","columns":[{"name":"title","type":"varchar(255)","nullable":false,"default":null,"comment":""}],"indexes":[],"constraints":[],"triggers":[],"def":"CREATE VIEW \"name with spaces\" AS (\n SELECT TOP 1 p.title\n FROM posts AS p\n);","referenced_tables":["posts"]},{"name":"Sales.Product","type":"BASIC TABLE","comment":"","columns":[{"name":"ProductID","type":"int","nullable":false,"default":null,"comment":""},{"name":"SalesPersonID","type":"int","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PK__Product_*","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ ProductID ]","table":"Sales.Product","columns":["ProductID"],"comment":""},{"name":"UQ__Product_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ SalesPersonID ]","table":"Sales.Product","columns":["SalesPersonID"],"comment":""}],"constraints":[{"name":"PK__Product_*","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ ProductID ]","table":"Sales.Product","referenced_table":null,"columns":["ProductID"],"referenced_columns":null,"comment":""},{"name":"UQ__Product_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ SalesPersonID ]","table":"Sales.Product","referenced_table":null,"columns":["SalesPersonID"],"referenced_columns":null,"comment":""}],"triggers":[],"def":""},{"name":"Rabbits.Running","type":"BASIC TABLE","comment":"","columns":[{"name":"LocationID","type":"int","nullable":false,"default":null,"comment":""},{"name":"ProductID","type":"int","nullable":true,"default":null,"comment":""},{"name":"EmployeeID","type":"int","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PK__Running_*","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ LocationID ]","table":"Rabbits.Running","columns":["LocationID"],"comment":""},{"name":"UQ__Running_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ EmployeeID ]","table":"Rabbits.Running","columns":["EmployeeID"],"comment":""},{"name":"UQ__Running_*","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ ProductID ]","table":"Rabbits.Running","columns":["ProductID"],"comment":""}],"constraints":[{"name":"PK__Running_*","type":"PRIMARY KEY","def":"CLUSTERED, unique, part of a PRIMARY KEY constraint, [ LocationID ]","table":"Rabbits.Running","referenced_table":null,"columns":["LocationID"],"referenced_columns":null,"comment":""},{"name":"UQ__Running_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ EmployeeID ]","table":"Rabbits.Running","referenced_table":null,"columns":["EmployeeID"],"referenced_columns":null,"comment":""},{"name":"UQ__Running_*","type":"UNIQUE","def":"NONCLUSTERED, unique, part of a UNIQUE constraint, [ ProductID ]","table":"Rabbits.Running","referenced_table":null,"columns":["ProductID"],"referenced_columns":null,"comment":""},{"name":"FK_TempSales_SalesReason","type":"FOREIGN KEY","def":"FOREIGN KEY(ProductID) REFERENCES Sales.Product(SalesPersonID) ON UPDATE NO_ACTION ON DELETE NO_ACTION","table":"Rabbits.Running","referenced_table":"Sales.Product","columns":["ProductID"],"referenced_columns":["SalesPersonID"],"comment":""}],"triggers":[],"def":""}],"relations":[{"table":"user_options","columns":["user_id"],"cardinality":"Zero or one","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"posts","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"comments","columns":["post_id"],"cardinality":"Zero or more","parent_table":"posts","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"comments","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"comment_stars","columns":["comment_user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"comment_stars","columns":["comment_post_id","comment_user_id"],"cardinality":"Zero or more","parent_table":"comments","parent_columns":["post_id","user_id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"administrator.blogs","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"","virtual":false},{"table":"Rabbits.Running","columns":["ProductID"],"cardinality":"Zero or one","parent_table":"Sales.Product","parent_columns":["SalesPersonID"],"parent_cardinality":"Zero or one","def":"","virtual":false},{"table":"logs","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"logs-\u003eusers","virtual":true},{"table":"logs","columns":["post_id"],"cardinality":"Zero or more","parent_table":"posts","parent_columns":["id"],"parent_cardinality":"Zero or one","def":"Additional Relation","virtual":true},{"table":"logs","columns":["comment_id"],"cardinality":"Zero or more","parent_table":"comments","parent_columns":["id"],"parent_cardinality":"Zero or one","def":"Additional Relation","virtual":true},{"table":"logs","columns":["comment_star_id"],"cardinality":"Zero or more","parent_table":"comment_stars","parent_columns":["id"],"parent_cardinality":"Zero or one","def":"Additional Relation","virtual":true}],"functions":[{"name":"dbo.get_user","return_type":"","arguments":"@userid int","type":"SQL inline table-valued function"},{"name":"dbo.What_DB_is_that","return_type":"","arguments":"@ID int","type":"SQL Stored Procedure"}],"driver":{"name":"sqlserver","database_version":"Microsoft SQL Server 2017 (RTM-CU31-GDR) (KB5029376) - 14.0.3465.1 (X64) \n\tJul 30 2023 15:31:58 \n\tCopyright (C) 2017 Microsoft Corporation\n\tDeveloper Edition (64-bit) on Linux (Ubuntu 18.04.6 LTS)","meta":{"dict":{"Functions":"Stored procedures and functions"}}},"labels":[{"Name":"sample","Virtual":true},{"Name":"tbls","Virtual":true}]} diff --git a/sample/mssql/schema.svg b/sample/mssql/schema.svg index fc04c709..00c04cf1 100644 --- a/sample/mssql/schema.svg +++ b/sample/mssql/schema.svg @@ -4,380 +4,380 @@ - + testdb - - - -Rabbits.Running - - -Rabbits.Running -     -[BASIC TABLE] - -LocationID     -[int] - -ProductID     -[int] - -EmployeeID     -[int] - - - -Sales.Product - - -Sales.Product -     -[BASIC TABLE] - -ProductID     -[int] - -SalesPersonID     -[int] - - - -Rabbits.Running:ProductID->Sales.Product:SalesPersonID - - - + - + users - - -users -     -[BASIC TABLE] - -id     -[int] - -username     -[varchar(50)] - -password     -[varchar(50)] - -email     -[varchar(355)] - -created     -[date] - -updated     -[date] + + +users +     +[BASIC TABLE] + +id     +[int] + +username     +[varchar(50)] + +password     +[varchar(50)] + +email     +[varchar(355)] + +created     +[date] + +updated     +[date] - + user_options - - -user_options -     -[BASIC TABLE] - -user_id     -[int] - -show_email     -[bit] - -created     -[date] - -updated     -[date] + + +user_options +     +[BASIC TABLE] + +user_id     +[int] + +show_email     +[bit] + +created     +[date] + +updated     +[date] - + user_options:user_id->users:id - - + + - + posts - - -posts -     -[BASIC TABLE] - -id     -[int] - -user_id     -[int] - -title     -[varchar(255)] - -body     -[text] - -created     -[date] - -updated     -[date] + + +posts +     +[BASIC TABLE] + +id     +[int] + +user_id     +[int] + +title     +[varchar(255)] + +body     +[text] + +created     +[date] + +updated     +[date] - + posts:user_id->users:id - - + + - + comments - - -comments -     -[BASIC TABLE] - -id     -[int] - -post_id     -[int] - -user_id     -[int] - -comment     -[text] - -created     -[date] - -updated     -[date] + + +comments +     +[BASIC TABLE] + +id     +[int] + +post_id     +[int] + +user_id     +[int] + +comment     +[text] + +created     +[date] + +updated     +[date] - + comments:user_id->users:id - - + + - + comments:post_id->posts:id - - + + - + comment_stars - - -comment_stars -     -[BASIC TABLE] - -id     -[int] - -user_id     -[int] - -comment_post_id     -[int] - -comment_user_id     -[int] - -created     -[date] - -updated     -[date] + + +comment_stars +     +[BASIC TABLE] + +id     +[int] + +user_id     +[int] + +comment_post_id     +[int] + +comment_user_id     +[int] + +created     +[date] + +updated     +[date] - + comment_stars:comment_user_id->users:id - - + + - + comment_stars:comment_post_id->comments:post_id - - + + - + logs - - -logs -     -[BASIC TABLE] - -id     -[int] - -user_id     -[int] - -post_id     -[int] - -comment_id     -[int] - -comment_star_id     -[int] - -payload     -[text] - -created     -[date] + + +logs +     +[BASIC TABLE] + +id     +[int] + +user_id     +[int] + +post_id     +[int] + +comment_id     +[int] + +comment_star_id     +[int] + +payload     +[text] + +created     +[date] logs:user_id->users:id - - -logs->users + + +logs->users logs:post_id->posts:id - - -Additional Relation + + +Additional Relation logs:comment_id->comments:id - - -Additional Relation + + +Additional Relation logs:comment_star_id->comment_stars:id - - -Additional Relation + + +Additional Relation - + post_comments - - -post_comments -     -[VIEW] - -id     -[int] - -title     -[varchar(255)] - -post_user     -[varchar(50)] - -comment     -[text] - -comment_user     -[varchar(50)] - -created     -[date] - -updated     -[date] + + +post_comments +     +[VIEW] + +id     +[int] + +title     +[varchar(255)] + +post_user     +[varchar(50)] + +comment     +[text] + +comment_user     +[varchar(50)] + +created     +[date] + +updated     +[date] - + CamelizeTable - - -CamelizeTable -     -[BASIC TABLE] - -id     -[int] - -created     -[date] + + +CamelizeTable +     +[BASIC TABLE] + +id     +[int] + +created     +[date] - + hyphen-table - - -hyphen-table -     -[BASIC TABLE] - -id     -[int] - -hyphen-column     -[text] - -created     -[date] + + +hyphen-table +     +[BASIC TABLE] + +id     +[int] + +hyphen-column     +[text] + +created     +[date] - + administrator.blogs - - -administrator.blogs -     -[BASIC TABLE] - -id     -[int] - -user_id     -[int] - -name     -[text] - -description     -[text] - -created     -[date] - -updated     -[date] + + +administrator.blogs +     +[BASIC TABLE] + +id     +[int] + +user_id     +[int] + +name     +[text] + +description     +[text] + +created     +[date] + +updated     +[date] - + administrator.blogs:user_id->users:id - - + + - + name with spaces - - -name with spaces -     -[VIEW] - -title     -[varchar(255)] + + +name with spaces +     +[VIEW] + +title     +[varchar(255)] + + + +Sales.Product + + +Sales.Product +     +[BASIC TABLE] + +ProductID     +[int] + +SalesPersonID     +[int] + + + +Rabbits.Running + + +Rabbits.Running +     +[BASIC TABLE] + +LocationID     +[int] + +ProductID     +[int] + +EmployeeID     +[int] + + + +Rabbits.Running:ProductID->Sales.Product:SalesPersonID + +