k1LoW / tbls

tbls is a CI-Friendly tool for document a database, written in Go.
MIT License
3.32k stars 164 forks source link

Distinguish Views from Tables in README.md #543

Closed majimaccho closed 7 months ago

majimaccho commented 7 months ago

Hi I'm really thankful for you to maintain this great tool!

I think it would be nicer if we can see which tables are actually table and are view.

The interface of view can be same as table and I simply want it to be separated from "Tables" section.

In README.md, I'm expecting in a format like below.

## Tables

| name | ... | ... |
| --- | --- | ---| 
| hoge_tables | ... | ... |

## Views
| name | ... | ... |
| --- | --- | ---| 
| fuga_views | ... | ... |

I suppose to implement this, It needs to check Table.type but as long as I see, it's not uniformed in RDBMS. Mysql and postgresql have VIEW as Table.type but sqlite has view in lower case. If you have any ideas about how to handle them and tell me it, I'm pleased.

Thank you!

k1LoW commented 7 months ago

Thank you for your proposal!!!

Your suggestion makes a lot of sense. However, I don't think it is a strong reason to split the tables by table type at this time.

Because BASE TABLE and VIEW are the same table, just of different types.

my:root@localhost:33308/testdb=> SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = 'testdb';
                     TABLE_NAME                     | TABLE_TYPE
----------------------------------------------------+------------
 CamelizeTable                                      | BASE TABLE
 comment_stars                                      | BASE TABLE
 comments                                           | BASE TABLE
 hyphen-table                                       | BASE TABLE
 logs                                               | BASE TABLE
 long_long_long_long_long_long_long_long_table_name | BASE TABLE
 post_comments                                      | VIEW
 posts                                              | BASE TABLE
 user_options                                       | BASE TABLE
 users                                              | BASE TABLE
(10 rows)

For example, PostgreSQL has a table type called MATERIALIZED VIEW.

https://github.com/k1LoW/tbls/blob/main/sample/postgres/README.md

In your proposal, should we also separate MATERIALIZED VIEW and VIEW?

Anyway, we think we need a stronger reason to split the tables by table type.

Thank you!!

majimaccho commented 7 months ago

@k1LoW Thank you for your response and I got your point. It's probably natural for people who usually query information_schema via SQL. I just wanted not to mix view and table up since they are different in many ways.

Can we simply add "type" column to "tables" table?

In your proposal, should we also separate MATERIALIZED VIEW and VIEW?

I don't have very strong opinion to this but, yes, I suppose it should be separated too.

k1LoW commented 7 months ago

Can we simply add "type" column to "tables" table?

You mean this?

CleanShot 2023-12-01 at 14 44 47@2x

https://github.com/k1LoW/tbls/blob/main/sample/mysql/README.md

majimaccho commented 7 months ago

Oh, No. There are. Sorry I just missed them. 😵‍💫 It just works for me!

k1LoW commented 7 months ago

👍