Grouping tables within a MySQL database
开发者_Python百科Here's my ponder: I've got some ER diagrams representing several thousand tables in a database. The entities represented in each of the multiple files have some associative relationship as decided by the designer. While relationships exist between entities in other files, they are not mapped. This seems common practice for diagramming databases of this size.
I was entertaining the idea of representing these groupings in a MySQL database. As SCHEMA is an alias to DATABASE in MySQL, I'm not able to find a mechanism for grouping tables within a database.
I'm wondering if anyone else has devised some creative grouping concept that they would like to share with me. Or, better yet, if MySQL supports some mechanism for grouping tables within a database, please let me know. ( I've apparently missed it in my research )
You can use the same prefix for the tables you want to use, for example you have employees groups you make the tables emp_main and emp_Children and emp_tasks then you can have another group like items that you sell that starts all with it_
There is no concept of a hierarchy in MySQL. ie. No folders, containers or namespaces for your databases.
MySQL has 2 concepts: A database (Often referred to as a Schema), and tables. Various software (like PHPMyAdmin) will look at the similarities and will group databases together into folders based on the name itself. For example, if you use underscores "com_sumeet"
phpmyadmin will actually group those together:
Unlike how Schemas in Postresql can be used to group tables into different namespaces, MySQL does not have native support for structuring tables in any other way than with prefixes. If you are using an admin tool like MySQL Workbench you can however use EER layers to group tables visually: https://dev.mysql.com/doc/workbench/en/wb-using-layer-tool.html
MySQL has the MERGE Storage Engine, which can aggregate a few tables with the same structure.
精彩评论