diff --git a/sample/viewpoints/logs.md b/sample/viewpoints/logs.md index f5dc49e1f..011b16e67 100644 --- a/sample/viewpoints/logs.md +++ b/sample/viewpoints/logs.md @@ -34,6 +34,12 @@ CREATE TABLE `logs` ( | payload | text | | true | | | | | | created | datetime | | false | | | | | +## Viewpoints + +| Name | Definition | +| ---- | ---------- | +| [Ops](viewpoint-1.md) | Tables to be referenced during operation | + ## Constraints | Name | Type | Definition | diff --git a/sample/viewpoints/posts.md b/sample/viewpoints/posts.md index 0021f6582..5d18f52c8 100644 --- a/sample/viewpoints/posts.md +++ b/sample/viewpoints/posts.md @@ -41,6 +41,12 @@ CREATE TABLE `posts` ( | created | datetime | | false | | | | | | | updated | datetime | | true | | | | | | +## Viewpoints + +| Name | Definition | +| ---- | ---------- | +| [Ops](viewpoint-1.md) | Tables to be referenced during operation | + ## Constraints | Name | Type | Definition | diff --git a/sample/viewpoints/schema.json b/sample/viewpoints/schema.json index cfa458c42..e1e5bf492 100644 --- a/sample/viewpoints/schema.json +++ b/sample/viewpoints/schema.json @@ -1 +1 @@ -{"name":"testdb","desc":"Sample database document.","tables":[{"name":"CamelizeTable","type":"BASE TABLE","comment":"","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"created","type":"datetime","nullable":false,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"CamelizeTable","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"CamelizeTable","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `CamelizeTable` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `created` datetime NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"},{"name":"comment_stars","type":"BASE TABLE","comment":"","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":"","labels":[{"Name":"user","Virtual":true}]},{"name":"comment_post_id","type":"bigint","nullable":false,"default":null,"comment":""},{"name":"comment_user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"created","type":"timestamp","nullable":false,"default":null,"comment":""},{"name":"updated","type":"timestamp","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"comment_stars_user_id_fk","def":"KEY comment_stars_user_id_fk (comment_user_id) USING BTREE","table":"comment_stars","columns":["comment_user_id"],"comment":""},{"name":"comment_stars_user_id_post_id_fk","def":"KEY comment_stars_user_id_post_id_fk (comment_post_id, comment_user_id) USING BTREE","table":"comment_stars","columns":["comment_post_id","comment_user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"comment_stars","columns":["id"],"comment":""},{"name":"user_id","def":"UNIQUE KEY user_id (user_id, comment_post_id, comment_user_id) USING BTREE","table":"comment_stars","columns":["user_id","comment_post_id","comment_user_id"],"comment":""}],"constraints":[{"name":"comment_stars_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY (comment_user_id) REFERENCES users (id)","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)","table":"comment_stars","referenced_table":"comments","columns":["comment_post_id","comment_user_id"],"referenced_columns":["post_id","user_id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"comment_stars","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"user_id","type":"UNIQUE","def":"UNIQUE KEY user_id (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":""}],"triggers":[],"def":"CREATE TABLE `comment_stars` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `user_id` int NOT NULL,\n `comment_post_id` bigint NOT NULL,\n `comment_user_id` int NOT NULL,\n `created` timestamp NOT NULL,\n `updated` timestamp NULL DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `user_id` (`user_id`,`comment_post_id`,`comment_user_id`),\n KEY `comment_stars_user_id_post_id_fk` (`comment_post_id`,`comment_user_id`),\n KEY `comment_stars_user_id_fk` (`comment_user_id`),\n CONSTRAINT `comment_stars_user_id_fk` FOREIGN KEY (`comment_user_id`) REFERENCES `users` (`id`),\n CONSTRAINT `comment_stars_user_id_post_id_fk` FOREIGN KEY (`comment_post_id`, `comment_user_id`) REFERENCES `comments` (`post_id`, `user_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci","labels":[{"Name":"content","Virtual":true}]},{"name":"comments","type":"BASE TABLE","comment":"Comments\nMulti-line\r\ntable\rcomment","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"post_id","type":"bigint","nullable":false,"default":null,"comment":""},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":"","labels":[{"Name":"user","Virtual":true}]},{"name":"comment","type":"text","nullable":false,"default":null,"comment":"Comment\nMulti-line\r\ncolumn\rcomment"},{"name":"post_id_desc","type":"bigint","nullable":true,"default":null,"comment":"","extra_def":"GENERATED ALWAYS AS (`post_id` * -(1)) VIRTUAL"},{"name":"created","type":"datetime","nullable":false,"default":null,"comment":""},{"name":"updated","type":"datetime","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"comments_post_id_user_id_idx","def":"KEY comments_post_id_user_id_idx (post_id, user_id) USING BTREE","table":"comments","columns":["post_id","user_id"],"comment":""},{"name":"comments_user_id_fk","def":"KEY comments_user_id_fk (user_id) USING BTREE","table":"comments","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"comments","columns":["id"],"comment":""},{"name":"post_id","def":"UNIQUE KEY post_id (post_id, user_id) USING BTREE","table":"comments","columns":["post_id","user_id"],"comment":""}],"constraints":[{"name":"comments_post_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY (post_id) REFERENCES posts (id)","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)","table":"comments","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"post_id","type":"UNIQUE","def":"UNIQUE KEY post_id (post_id, user_id)","table":"comments","referenced_table":null,"columns":["post_id","user_id"],"referenced_columns":null,"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"comments","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `comments` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `post_id` bigint NOT NULL,\n `user_id` int NOT NULL,\n `comment` text NOT NULL COMMENT 'Comment\\nMulti-line\\r\\ncolumn\\rcomment',\n `post_id_desc` bigint GENERATED ALWAYS AS ((`post_id` * -(1))) VIRTUAL,\n `created` datetime NOT NULL,\n `updated` datetime DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `post_id` (`post_id`,`user_id`),\n KEY `comments_user_id_fk` (`user_id`),\n KEY `comments_post_id_user_id_idx` (`post_id`,`user_id`),\n CONSTRAINT `comments_post_id_fk` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`),\n CONSTRAINT `comments_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Comments\\nMulti-line\\r\\ntable\\rcomment'","labels":[{"Name":"content","Virtual":true}]},{"name":"hyphen-table","type":"BASE TABLE","comment":"","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"hyphen-column","type":"text","nullable":false,"default":null,"comment":""},{"name":"created","type":"datetime","nullable":false,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"hyphen-table","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"hyphen-table","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `hyphen-table` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `hyphen-column` text NOT NULL,\n `created` datetime NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"},{"name":"logs","type":"BASE TABLE","comment":"Auditログ","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"post_id","type":"bigint","nullable":true,"default":null,"comment":""},{"name":"comment_id","type":"bigint","nullable":true,"default":null,"comment":""},{"name":"comment_star_id","type":"bigint","nullable":true,"default":null,"comment":""},{"name":"payload","type":"text","nullable":true,"default":null,"comment":""},{"name":"created","type":"datetime","nullable":false,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"logs","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"logs","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `logs` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `user_id` int NOT NULL,\n `post_id` bigint DEFAULT NULL,\n `comment_id` bigint DEFAULT NULL,\n `comment_star_id` bigint DEFAULT NULL,\n `payload` text,\n `created` datetime NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Auditログ'"},{"name":"long_long_long_long_long_long_long_long_table_name","type":"BASE TABLE","comment":"","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"created","type":"datetime","nullable":false,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"long_long_long_long_long_long_long_long_table_name","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"long_long_long_long_long_long_long_long_table_name","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `long_long_long_long_long_long_long_long_table_name` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `created` datetime NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"},{"name":"post_comments","type":"VIEW","comment":"post and comments View table","columns":[{"name":"id","type":"bigint","nullable":true,"default":"0","comment":"comments.id"},{"name":"title","type":"varchar(255)","nullable":false,"default":"Untitled","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":"Comment\nMulti-line\r\ncolumn\rcomment"},{"name":"comment_user","type":"varchar(50)","nullable":true,"default":null,"comment":"comments.users.username"},{"name":"created","type":"datetime","nullable":true,"default":null,"comment":"comments.created"},{"name":"updated","type":"datetime","nullable":true,"default":null,"comment":"comments.updated"}],"indexes":[],"constraints":[],"triggers":[],"def":"CREATE VIEW post_comments AS (select `c`.`id` AS `id`,`p`.`title` AS `title`,`u2`.`username` AS `post_user`,`c`.`comment` AS `comment`,`u2`.`username` AS `comment_user`,`c`.`created` AS `created`,`c`.`updated` AS `updated` from (((`testdb`.`posts` `p` left join `testdb`.`comments` `c` on((`p`.`id` = `c`.`post_id`))) left join `testdb`.`users` `u` on((`u`.`id` = `p`.`user_id`))) left join `testdb`.`users` `u2` on((`u2`.`id` = `c`.`user_id`))))","labels":[{"Name":"content","Virtual":true}],"referenced_tables":["posts","comments","users"]},{"name":"posts","type":"BASE TABLE","comment":"Posts table","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":"","labels":[{"Name":"user","Virtual":true}]},{"name":"title","type":"varchar(255)","nullable":false,"default":"Untitled","comment":""},{"name":"body","type":"text","nullable":false,"default":null,"comment":"post body"},{"name":"post_type","type":"enum('public','private','draft')","nullable":false,"default":null,"comment":"public/private/draft"},{"name":"created","type":"datetime","nullable":false,"default":null,"comment":""},{"name":"updated","type":"datetime","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"posts_user_id_idx","def":"KEY posts_user_id_idx (id) USING BTREE","table":"posts","columns":["id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"posts","columns":["id"],"comment":""},{"name":"user_id","def":"UNIQUE KEY user_id (user_id, title) USING BTREE","table":"posts","columns":["user_id","title"],"comment":""}],"constraints":[{"name":"posts_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"posts","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"posts","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"user_id","type":"UNIQUE","def":"UNIQUE KEY user_id (user_id, title)","table":"posts","referenced_table":null,"columns":["user_id","title"],"referenced_columns":null,"comment":""}],"triggers":[{"name":"update_posts_updated","def":"CREATE TRIGGER update_posts_updated BEFORE UPDATE ON posts\nFOR EACH ROW\nSET NEW.updated = CURRENT_TIMESTAMP()","comment":""}],"def":"CREATE TABLE `posts` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `user_id` int NOT NULL,\n `title` varchar(255) NOT NULL DEFAULT 'Untitled',\n `body` text NOT NULL,\n `post_type` enum('public','private','draft') NOT NULL COMMENT 'public/private/draft',\n `created` datetime NOT NULL,\n `updated` datetime DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `user_id` (`user_id`,`title`),\n KEY `posts_user_id_idx` (`id`) USING BTREE,\n CONSTRAINT `posts_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Posts table'","labels":[{"Name":"content","Virtual":true}]},{"name":"user_options","type":"BASE TABLE","comment":"User options table","columns":[{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"show_email","type":"tinyint(1)","nullable":false,"default":"0","comment":""},{"name":"created","type":"timestamp","nullable":false,"default":null,"comment":""},{"name":"updated","type":"timestamp","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (user_id) USING BTREE","table":"user_options","columns":["user_id"],"comment":""},{"name":"user_id","def":"UNIQUE KEY user_id (user_id) USING BTREE","table":"user_options","columns":["user_id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (user_id)","table":"user_options","referenced_table":null,"columns":["user_id"],"referenced_columns":null,"comment":""},{"name":"user_id","type":"UNIQUE","def":"UNIQUE KEY user_id (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)","table":"user_options","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""}],"triggers":[],"def":"CREATE TABLE `user_options` (\n `user_id` int NOT NULL,\n `show_email` tinyint(1) NOT NULL DEFAULT '0',\n `created` timestamp NOT NULL,\n `updated` timestamp NULL DEFAULT NULL,\n PRIMARY KEY (`user_id`),\n UNIQUE KEY `user_id` (`user_id`),\n CONSTRAINT `user_options_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='User options table'","labels":[{"Name":"user","Virtual":true}]},{"name":"users","type":"BASE TABLE","comment":"Users table","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"username","type":"varchar(50)","nullable":false,"default":null,"comment":""},{"name":"password","type":"varchar(50)","nullable":false,"default":null,"comment":"","labels":[{"Name":"secure","Virtual":true},{"Name":"encrypted","Virtual":true}]},{"name":"email","type":"varchar(355)","nullable":false,"default":null,"comment":"ex. user@example.com","labels":[{"Name":"secure","Virtual":true}]},{"name":"created","type":"timestamp","nullable":false,"default":null,"comment":""},{"name":"updated","type":"timestamp","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"users","columns":["id"],"comment":""},{"name":"email","def":"UNIQUE KEY email (email) USING BTREE","table":"users","columns":["email"],"comment":""},{"name":"username","def":"UNIQUE KEY username (username) USING BTREE","table":"users","columns":["username"],"comment":""}],"constraints":[{"name":"email","type":"UNIQUE","def":"UNIQUE KEY email (email)","table":"users","referenced_table":null,"columns":["email"],"referenced_columns":null,"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"users","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"username","type":"UNIQUE","def":"UNIQUE KEY username (username)","table":"users","referenced_table":null,"columns":["username"],"referenced_columns":null,"comment":""},{"name":"users_chk_1","type":"CHECK","def":"CHECK ((char_length(`username`) \u003e 4))","table":"users","referenced_table":null,"columns":null,"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `users` (\n `id` int NOT NULL AUTO_INCREMENT,\n `username` varchar(50) NOT NULL,\n `password` varchar(50) NOT NULL,\n `email` varchar(355) NOT NULL COMMENT 'ex. user@example.com',\n `created` timestamp NOT NULL,\n `updated` timestamp NULL DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `username` (`username`),\n UNIQUE KEY `email` (`email`),\n CONSTRAINT `users_chk_1` CHECK ((char_length(`username`) \u003e 4))\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Users table'","labels":[{"Name":"user","Virtual":true}]}],"relations":[{"table":"comment_stars","columns":["comment_user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (comment_user_id) REFERENCES users (id)","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":"FOREIGN KEY (comment_post_id, comment_user_id) REFERENCES comments (post_id, user_id)","virtual":false},{"table":"comments","columns":["post_id"],"cardinality":"Zero or more","parent_table":"posts","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (post_id) REFERENCES posts (id)","virtual":false},{"table":"comments","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"posts","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"user_options","columns":["user_id"],"cardinality":"Zero or one","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","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":"CustomerLevel","return_type":"varchar","arguments":"credit decimal","type":"FUNCTION"},{"name":"GetAllComments","return_type":"","arguments":"","type":"PROCEDURE"}],"driver":{"name":"mysql","database_version":"8.0.32","meta":{"dict":{"Functions":"Stored procedures and functions"}}},"labels":[{"Name":"sample","Virtual":true},{"Name":"tbls","Virtual":true}],"viewpoints":[{"name":"Content","desc":"Content as an asset for blogging services","labels":["content"]},{"name":"Ops","desc":"Tables to be referenced during operation","tables":["logs","users","posts"]},{"name":"Around the users table","desc":"Tables related to the users table","tables":["users"],"distance":1,"groups":[{"name":"Content","desc":"Content as an asset for blogging services","labels":["content"]}]},{"name":"Secure data","desc":"Tables with secure data","labels":["secure"]}]} +{"name":"testdb","desc":"Sample database document.","tables":[{"name":"CamelizeTable","type":"BASE TABLE","comment":"","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"created","type":"datetime","nullable":false,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"CamelizeTable","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"CamelizeTable","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `CamelizeTable` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `created` datetime NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"},{"name":"comment_stars","type":"BASE TABLE","comment":"","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":"","labels":[{"Name":"user","Virtual":true}]},{"name":"comment_post_id","type":"bigint","nullable":false,"default":null,"comment":""},{"name":"comment_user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"created","type":"timestamp","nullable":false,"default":null,"comment":""},{"name":"updated","type":"timestamp","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"comment_stars_user_id_fk","def":"KEY comment_stars_user_id_fk (comment_user_id) USING BTREE","table":"comment_stars","columns":["comment_user_id"],"comment":""},{"name":"comment_stars_user_id_post_id_fk","def":"KEY comment_stars_user_id_post_id_fk (comment_post_id, comment_user_id) USING BTREE","table":"comment_stars","columns":["comment_post_id","comment_user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"comment_stars","columns":["id"],"comment":""},{"name":"user_id","def":"UNIQUE KEY user_id (user_id, comment_post_id, comment_user_id) USING BTREE","table":"comment_stars","columns":["user_id","comment_post_id","comment_user_id"],"comment":""}],"constraints":[{"name":"comment_stars_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY (comment_user_id) REFERENCES users (id)","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)","table":"comment_stars","referenced_table":"comments","columns":["comment_post_id","comment_user_id"],"referenced_columns":["post_id","user_id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"comment_stars","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"user_id","type":"UNIQUE","def":"UNIQUE KEY user_id (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":""}],"triggers":[],"def":"CREATE TABLE `comment_stars` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `user_id` int NOT NULL,\n `comment_post_id` bigint NOT NULL,\n `comment_user_id` int NOT NULL,\n `created` timestamp NOT NULL,\n `updated` timestamp NULL DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `user_id` (`user_id`,`comment_post_id`,`comment_user_id`),\n KEY `comment_stars_user_id_post_id_fk` (`comment_post_id`,`comment_user_id`),\n KEY `comment_stars_user_id_fk` (`comment_user_id`),\n CONSTRAINT `comment_stars_user_id_fk` FOREIGN KEY (`comment_user_id`) REFERENCES `users` (`id`),\n CONSTRAINT `comment_stars_user_id_post_id_fk` FOREIGN KEY (`comment_post_id`, `comment_user_id`) REFERENCES `comments` (`post_id`, `user_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci","labels":[{"Name":"content","Virtual":true}]},{"name":"comments","type":"BASE TABLE","comment":"Comments\nMulti-line\r\ntable\rcomment","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"post_id","type":"bigint","nullable":false,"default":null,"comment":""},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":"","labels":[{"Name":"user","Virtual":true}]},{"name":"comment","type":"text","nullable":false,"default":null,"comment":"Comment\nMulti-line\r\ncolumn\rcomment"},{"name":"post_id_desc","type":"bigint","nullable":true,"default":null,"comment":"","extra_def":"GENERATED ALWAYS AS (`post_id` * -(1)) VIRTUAL"},{"name":"created","type":"datetime","nullable":false,"default":null,"comment":""},{"name":"updated","type":"datetime","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"comments_post_id_user_id_idx","def":"KEY comments_post_id_user_id_idx (post_id, user_id) USING BTREE","table":"comments","columns":["post_id","user_id"],"comment":""},{"name":"comments_user_id_fk","def":"KEY comments_user_id_fk (user_id) USING BTREE","table":"comments","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"comments","columns":["id"],"comment":""},{"name":"post_id","def":"UNIQUE KEY post_id (post_id, user_id) USING BTREE","table":"comments","columns":["post_id","user_id"],"comment":""}],"constraints":[{"name":"comments_post_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY (post_id) REFERENCES posts (id)","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)","table":"comments","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"post_id","type":"UNIQUE","def":"UNIQUE KEY post_id (post_id, user_id)","table":"comments","referenced_table":null,"columns":["post_id","user_id"],"referenced_columns":null,"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"comments","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `comments` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `post_id` bigint NOT NULL,\n `user_id` int NOT NULL,\n `comment` text NOT NULL COMMENT 'Comment\\nMulti-line\\r\\ncolumn\\rcomment',\n `post_id_desc` bigint GENERATED ALWAYS AS ((`post_id` * -(1))) VIRTUAL,\n `created` datetime NOT NULL,\n `updated` datetime DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `post_id` (`post_id`,`user_id`),\n KEY `comments_user_id_fk` (`user_id`),\n KEY `comments_post_id_user_id_idx` (`post_id`,`user_id`),\n CONSTRAINT `comments_post_id_fk` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`),\n CONSTRAINT `comments_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Comments\\nMulti-line\\r\\ntable\\rcomment'","labels":[{"Name":"content","Virtual":true}]},{"name":"hyphen-table","type":"BASE TABLE","comment":"","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"hyphen-column","type":"text","nullable":false,"default":null,"comment":""},{"name":"created","type":"datetime","nullable":false,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"hyphen-table","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"hyphen-table","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `hyphen-table` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `hyphen-column` text NOT NULL,\n `created` datetime NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"},{"name":"logs","type":"BASE TABLE","comment":"Auditログ","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"post_id","type":"bigint","nullable":true,"default":null,"comment":""},{"name":"comment_id","type":"bigint","nullable":true,"default":null,"comment":""},{"name":"comment_star_id","type":"bigint","nullable":true,"default":null,"comment":""},{"name":"payload","type":"text","nullable":true,"default":null,"comment":""},{"name":"created","type":"datetime","nullable":false,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"logs","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"logs","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `logs` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `user_id` int NOT NULL,\n `post_id` bigint DEFAULT NULL,\n `comment_id` bigint DEFAULT NULL,\n `comment_star_id` bigint DEFAULT NULL,\n `payload` text,\n `created` datetime NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Auditログ'"},{"name":"long_long_long_long_long_long_long_long_table_name","type":"BASE TABLE","comment":"","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"created","type":"datetime","nullable":false,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"long_long_long_long_long_long_long_long_table_name","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"long_long_long_long_long_long_long_long_table_name","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `long_long_long_long_long_long_long_long_table_name` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `created` datetime NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"},{"name":"post_comments","type":"VIEW","comment":"post and comments View table","columns":[{"name":"id","type":"bigint","nullable":true,"default":"0","comment":"comments.id"},{"name":"title","type":"varchar(255)","nullable":false,"default":"Untitled","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":"Comment\nMulti-line\r\ncolumn\rcomment"},{"name":"comment_user","type":"varchar(50)","nullable":true,"default":null,"comment":"comments.users.username"},{"name":"created","type":"datetime","nullable":true,"default":null,"comment":"comments.created"},{"name":"updated","type":"datetime","nullable":true,"default":null,"comment":"comments.updated"}],"indexes":[],"constraints":[],"triggers":[],"def":"CREATE VIEW post_comments AS (select `c`.`id` AS `id`,`p`.`title` AS `title`,`u2`.`username` AS `post_user`,`c`.`comment` AS `comment`,`u2`.`username` AS `comment_user`,`c`.`created` AS `created`,`c`.`updated` AS `updated` from (((`testdb`.`posts` `p` left join `testdb`.`comments` `c` on((`p`.`id` = `c`.`post_id`))) left join `testdb`.`users` `u` on((`u`.`id` = `p`.`user_id`))) left join `testdb`.`users` `u2` on((`u2`.`id` = `c`.`user_id`))))","labels":[{"Name":"content","Virtual":true}],"referenced_tables":["posts","comments","users"]},{"name":"posts","type":"BASE TABLE","comment":"Posts table","columns":[{"name":"id","type":"bigint","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"user_id","type":"int","nullable":false,"default":null,"comment":"","labels":[{"Name":"user","Virtual":true}]},{"name":"title","type":"varchar(255)","nullable":false,"default":"Untitled","comment":""},{"name":"body","type":"text","nullable":false,"default":null,"comment":"post body"},{"name":"post_type","type":"enum('public','private','draft')","nullable":false,"default":null,"comment":"public/private/draft"},{"name":"created","type":"datetime","nullable":false,"default":null,"comment":""},{"name":"updated","type":"datetime","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"posts_user_id_idx","def":"KEY posts_user_id_idx (id) USING BTREE","table":"posts","columns":["id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"posts","columns":["id"],"comment":""},{"name":"user_id","def":"UNIQUE KEY user_id (user_id, title) USING BTREE","table":"posts","columns":["user_id","title"],"comment":""}],"constraints":[{"name":"posts_user_id_fk","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"posts","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"posts","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"user_id","type":"UNIQUE","def":"UNIQUE KEY user_id (user_id, title)","table":"posts","referenced_table":null,"columns":["user_id","title"],"referenced_columns":null,"comment":""}],"triggers":[{"name":"update_posts_updated","def":"CREATE TRIGGER update_posts_updated BEFORE UPDATE ON posts\nFOR EACH ROW\nSET NEW.updated = CURRENT_TIMESTAMP()","comment":""}],"def":"CREATE TABLE `posts` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `user_id` int NOT NULL,\n `title` varchar(255) NOT NULL DEFAULT 'Untitled',\n `body` text NOT NULL,\n `post_type` enum('public','private','draft') NOT NULL COMMENT 'public/private/draft',\n `created` datetime NOT NULL,\n `updated` datetime DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `user_id` (`user_id`,`title`),\n KEY `posts_user_id_idx` (`id`) USING BTREE,\n CONSTRAINT `posts_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Posts table'","labels":[{"Name":"content","Virtual":true}]},{"name":"user_options","type":"BASE TABLE","comment":"User options table","columns":[{"name":"user_id","type":"int","nullable":false,"default":null,"comment":""},{"name":"show_email","type":"tinyint(1)","nullable":false,"default":"0","comment":""},{"name":"created","type":"timestamp","nullable":false,"default":null,"comment":""},{"name":"updated","type":"timestamp","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (user_id) USING BTREE","table":"user_options","columns":["user_id"],"comment":""},{"name":"user_id","def":"UNIQUE KEY user_id (user_id) USING BTREE","table":"user_options","columns":["user_id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (user_id)","table":"user_options","referenced_table":null,"columns":["user_id"],"referenced_columns":null,"comment":""},{"name":"user_id","type":"UNIQUE","def":"UNIQUE KEY user_id (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)","table":"user_options","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""}],"triggers":[],"def":"CREATE TABLE `user_options` (\n `user_id` int NOT NULL,\n `show_email` tinyint(1) NOT NULL DEFAULT '0',\n `created` timestamp NOT NULL,\n `updated` timestamp NULL DEFAULT NULL,\n PRIMARY KEY (`user_id`),\n UNIQUE KEY `user_id` (`user_id`),\n CONSTRAINT `user_options_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='User options table'","labels":[{"Name":"user","Virtual":true}]},{"name":"users","type":"BASE TABLE","comment":"Users table","columns":[{"name":"id","type":"int","nullable":false,"default":null,"comment":"","extra_def":"auto_increment"},{"name":"username","type":"varchar(50)","nullable":false,"default":null,"comment":""},{"name":"password","type":"varchar(50)","nullable":false,"default":null,"comment":"","labels":[{"Name":"secure","Virtual":true},{"Name":"encrypted","Virtual":true}]},{"name":"email","type":"varchar(355)","nullable":false,"default":null,"comment":"ex. user@example.com","labels":[{"Name":"secure","Virtual":true}]},{"name":"created","type":"timestamp","nullable":false,"default":null,"comment":""},{"name":"updated","type":"timestamp","nullable":true,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"users","columns":["id"],"comment":""},{"name":"email","def":"UNIQUE KEY email (email) USING BTREE","table":"users","columns":["email"],"comment":""},{"name":"username","def":"UNIQUE KEY username (username) USING BTREE","table":"users","columns":["username"],"comment":""}],"constraints":[{"name":"email","type":"UNIQUE","def":"UNIQUE KEY email (email)","table":"users","referenced_table":null,"columns":["email"],"referenced_columns":null,"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"users","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"username","type":"UNIQUE","def":"UNIQUE KEY username (username)","table":"users","referenced_table":null,"columns":["username"],"referenced_columns":null,"comment":""},{"name":"users_chk_1","type":"CHECK","def":"CHECK ((char_length(`username`) \u003e 4))","table":"users","referenced_table":null,"columns":null,"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `users` (\n `id` int NOT NULL AUTO_INCREMENT,\n `username` varchar(50) NOT NULL,\n `password` varchar(50) NOT NULL,\n `email` varchar(355) NOT NULL COMMENT 'ex. user@example.com',\n `created` timestamp NOT NULL,\n `updated` timestamp NULL DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `username` (`username`),\n UNIQUE KEY `email` (`email`),\n CONSTRAINT `users_chk_1` CHECK ((char_length(`username`) \u003e 4))\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Users table'","labels":[{"Name":"user","Virtual":true}]}],"relations":[{"table":"comment_stars","columns":["comment_user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (comment_user_id) REFERENCES users (id)","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":"FOREIGN KEY (comment_post_id, comment_user_id) REFERENCES comments (post_id, user_id)","virtual":false},{"table":"comments","columns":["post_id"],"cardinality":"Zero or more","parent_table":"posts","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (post_id) REFERENCES posts (id)","virtual":false},{"table":"comments","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"posts","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"user_options","columns":["user_id"],"cardinality":"Zero or one","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","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":"CustomerLevel","return_type":"varchar","arguments":"credit decimal","type":"FUNCTION"},{"name":"GetAllComments","return_type":"","arguments":"","type":"PROCEDURE"}],"driver":{"name":"mysql","database_version":"8.1.0","meta":{"dict":{"Functions":"Stored procedures and functions"}}},"labels":[{"Name":"sample","Virtual":true},{"Name":"tbls","Virtual":true}],"viewpoints":[{"name":"Content","desc":"Content as an asset for blogging services","labels":["content"]},{"name":"Ops","desc":"Tables to be referenced during operation","tables":["logs","users","posts"]},{"name":"Around the users table","desc":"Tables related to the users table","tables":["users"],"distance":1,"groups":[{"name":"Content","desc":"Content as an asset for blogging services","labels":["content"]}]},{"name":"Secure data","desc":"Tables with secure data","labels":["secure"]}]} diff --git a/sample/viewpoints/users.md b/sample/viewpoints/users.md index eda656f58..a21888a13 100644 --- a/sample/viewpoints/users.md +++ b/sample/viewpoints/users.md @@ -39,6 +39,13 @@ CREATE TABLE `users` ( | created | timestamp | | false | | | | | | | updated | timestamp | | true | | | | | | +## Viewpoints + +| Name | Definition | +| ---- | ---------- | +| [Ops](viewpoint-1.md) | Tables to be referenced during operation | +| [Around the users table](viewpoint-2.md) | Tables related to the users table | + ## Constraints | Name | Type | Definition |