MySQL CREATE VIEW targeting variable table name (columns names)Swapping column values in MySQLHow do I quickly rename a MySQL database (change schema name)?What is the naming convention in Python for variable and function names?How do you set a default value for a MySQL Datetime column?How to find all the tables in MySQL with specific column names in them?MySQL: @variable vs. variable. What's the difference?How to import CSV file to MySQL tableInsert into a MySQL table or update if existsHow to get the sizes of the tables of a MySQL database?How to reference a just created column in mysql view?

What's the big deal about the Nazgûl losing their horses?

When moving a unique_ptr into a lambda, why is it not possible to call reset?

Examples of fluid (including air) being used to transmit digital data?

Was it ever illegal to name a pig "Napoleon" in France?

Quotients of a ring of integers

How can I use my cell phone's light as a reading light?

Why is there paternal, for fatherly, fraternal, for brotherly, but no similar word for sons?

Who goes first? Person disembarking bus or the bicycle?

Is it ok for parents to kiss and romance with each other while their 2- to 8-year-old child watches?

Wouldn't putting an electronic key inside a small Faraday cage render it completely useless?

Why am I getting unevenly-spread results when using $RANDOM?

Attach a visible light telescope to the outside of the ISS

Which is a better conductor, a very thick rubber wire or a very thin copper wire?

When is one 'Ready' to make Original Contributions to Mathematics?

Gory anime with pink haired girl escaping an asylum

My professor has told me he will be the corresponding author. Will it hurt my future career?

Why do people prefer metropolitan areas, considering monsters and villains?

Why does "mi piace" mean "I like" instead of "he/she/it likes me"?

As a supervisor, what feedback would you expect from a PhD who quits?

Taking my Ph.D. advisor out for dinner after graduation

Did William Shakespeare hide things in his writings?

WPF Palindrome Checker Application

How should I ask for a "pint" in countries that use metric?

How does the cloaker's Phantasms action work?



MySQL CREATE VIEW targeting variable table name (columns names)


Swapping column values in MySQLHow do I quickly rename a MySQL database (change schema name)?What is the naming convention in Python for variable and function names?How do you set a default value for a MySQL Datetime column?How to find all the tables in MySQL with specific column names in them?MySQL: @variable vs. variable. What's the difference?How to import CSV file to MySQL tableInsert into a MySQL table or update if existsHow to get the sizes of the tables of a MySQL database?How to reference a just created column in mysql view?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to define a lot of views but the model of the DB is changing so there are some ideas/questions that came to my mind:



  1. Is there any way in MySQL 8 to create view that after FROM has not hardcoded table name but table name is a variable?


  2. Is it possible to create view that has hardcoded name of table after FROM but column names are variable?


  3. Is it a good idea to create a view (A) that after FROM does not target a particular (hardcoded) table name but another view (B) that works as intermediate translation table that does just select data from a table (C) and gives it back to view (A) with columns aliased the way the first view (A) expects them. In short 2nd view (B) just acts as a translator between (A) <=> (C) in terms of table name and column names?


The reason I'm thinking about these solutions is I want to have a set of table views for application that connects to DB. And they should not change but the whole model of DB will change.



I don't want to touch the access views that are an interface for application but rather define some connections between columns and tables behind the app interface view. Also the DB model will need some other views to do common calculations/reporting but the source table data to calculations/reporting will be altered over time (column names, table names).



  1. Is there any other approach I could apply? How do you deal with cases of altering table names, column names in DB without breaking already implemented reporting and other functionalities that expect a particular names of tables and columns?

I'm using MySQL 8.










share|improve this question




























    0















    I want to define a lot of views but the model of the DB is changing so there are some ideas/questions that came to my mind:



    1. Is there any way in MySQL 8 to create view that after FROM has not hardcoded table name but table name is a variable?


    2. Is it possible to create view that has hardcoded name of table after FROM but column names are variable?


    3. Is it a good idea to create a view (A) that after FROM does not target a particular (hardcoded) table name but another view (B) that works as intermediate translation table that does just select data from a table (C) and gives it back to view (A) with columns aliased the way the first view (A) expects them. In short 2nd view (B) just acts as a translator between (A) <=> (C) in terms of table name and column names?


    The reason I'm thinking about these solutions is I want to have a set of table views for application that connects to DB. And they should not change but the whole model of DB will change.



    I don't want to touch the access views that are an interface for application but rather define some connections between columns and tables behind the app interface view. Also the DB model will need some other views to do common calculations/reporting but the source table data to calculations/reporting will be altered over time (column names, table names).



    1. Is there any other approach I could apply? How do you deal with cases of altering table names, column names in DB without breaking already implemented reporting and other functionalities that expect a particular names of tables and columns?

    I'm using MySQL 8.










    share|improve this question
























      0












      0








      0








      I want to define a lot of views but the model of the DB is changing so there are some ideas/questions that came to my mind:



      1. Is there any way in MySQL 8 to create view that after FROM has not hardcoded table name but table name is a variable?


      2. Is it possible to create view that has hardcoded name of table after FROM but column names are variable?


      3. Is it a good idea to create a view (A) that after FROM does not target a particular (hardcoded) table name but another view (B) that works as intermediate translation table that does just select data from a table (C) and gives it back to view (A) with columns aliased the way the first view (A) expects them. In short 2nd view (B) just acts as a translator between (A) <=> (C) in terms of table name and column names?


      The reason I'm thinking about these solutions is I want to have a set of table views for application that connects to DB. And they should not change but the whole model of DB will change.



      I don't want to touch the access views that are an interface for application but rather define some connections between columns and tables behind the app interface view. Also the DB model will need some other views to do common calculations/reporting but the source table data to calculations/reporting will be altered over time (column names, table names).



      1. Is there any other approach I could apply? How do you deal with cases of altering table names, column names in DB without breaking already implemented reporting and other functionalities that expect a particular names of tables and columns?

      I'm using MySQL 8.










      share|improve this question














      I want to define a lot of views but the model of the DB is changing so there are some ideas/questions that came to my mind:



      1. Is there any way in MySQL 8 to create view that after FROM has not hardcoded table name but table name is a variable?


      2. Is it possible to create view that has hardcoded name of table after FROM but column names are variable?


      3. Is it a good idea to create a view (A) that after FROM does not target a particular (hardcoded) table name but another view (B) that works as intermediate translation table that does just select data from a table (C) and gives it back to view (A) with columns aliased the way the first view (A) expects them. In short 2nd view (B) just acts as a translator between (A) <=> (C) in terms of table name and column names?


      The reason I'm thinking about these solutions is I want to have a set of table views for application that connects to DB. And they should not change but the whole model of DB will change.



      I don't want to touch the access views that are an interface for application but rather define some connections between columns and tables behind the app interface view. Also the DB model will need some other views to do common calculations/reporting but the source table data to calculations/reporting will be altered over time (column names, table names).



      1. Is there any other approach I could apply? How do you deal with cases of altering table names, column names in DB without breaking already implemented reporting and other functionalities that expect a particular names of tables and columns?

      I'm using MySQL 8.







      mysql variables view interface translators






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 21:10









      JimmixJimmix

      1,0408 silver badges18 bronze badges




      1,0408 silver badges18 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          -1














          1. No

          2. No

          3. You can certainly do this and it is not uncommon to have views based on views. Whether it is a good idea, that's a matter of opinion.

          4. You cannot fully protect applications from underlying data model changes. If you introduce, remove, or change columns / columns in the data model, you must reflect them in the reports / applications, since the available content will change. If a table or column gets renamed, that can be hidden from the application through the use of views. However, if the rename is not that important so that you would reflect that in the report / application, then it begs the question why you need to rename the column.

          If your data structure changes so frequently, then an SQL-based product may not be the right thing for you, since SQL requires quite rigid definition of the data structure. You may have to consider a NoSql solution instead that allows greater flexibility in the database schema. However, data structure changes will affect the application / reporting even if you use a NoSql solution.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55346447%2fmysql-create-view-targeting-variable-table-name-columns-names%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            -1














            1. No

            2. No

            3. You can certainly do this and it is not uncommon to have views based on views. Whether it is a good idea, that's a matter of opinion.

            4. You cannot fully protect applications from underlying data model changes. If you introduce, remove, or change columns / columns in the data model, you must reflect them in the reports / applications, since the available content will change. If a table or column gets renamed, that can be hidden from the application through the use of views. However, if the rename is not that important so that you would reflect that in the report / application, then it begs the question why you need to rename the column.

            If your data structure changes so frequently, then an SQL-based product may not be the right thing for you, since SQL requires quite rigid definition of the data structure. You may have to consider a NoSql solution instead that allows greater flexibility in the database schema. However, data structure changes will affect the application / reporting even if you use a NoSql solution.






            share|improve this answer



























              -1














              1. No

              2. No

              3. You can certainly do this and it is not uncommon to have views based on views. Whether it is a good idea, that's a matter of opinion.

              4. You cannot fully protect applications from underlying data model changes. If you introduce, remove, or change columns / columns in the data model, you must reflect them in the reports / applications, since the available content will change. If a table or column gets renamed, that can be hidden from the application through the use of views. However, if the rename is not that important so that you would reflect that in the report / application, then it begs the question why you need to rename the column.

              If your data structure changes so frequently, then an SQL-based product may not be the right thing for you, since SQL requires quite rigid definition of the data structure. You may have to consider a NoSql solution instead that allows greater flexibility in the database schema. However, data structure changes will affect the application / reporting even if you use a NoSql solution.






              share|improve this answer

























                -1












                -1








                -1







                1. No

                2. No

                3. You can certainly do this and it is not uncommon to have views based on views. Whether it is a good idea, that's a matter of opinion.

                4. You cannot fully protect applications from underlying data model changes. If you introduce, remove, or change columns / columns in the data model, you must reflect them in the reports / applications, since the available content will change. If a table or column gets renamed, that can be hidden from the application through the use of views. However, if the rename is not that important so that you would reflect that in the report / application, then it begs the question why you need to rename the column.

                If your data structure changes so frequently, then an SQL-based product may not be the right thing for you, since SQL requires quite rigid definition of the data structure. You may have to consider a NoSql solution instead that allows greater flexibility in the database schema. However, data structure changes will affect the application / reporting even if you use a NoSql solution.






                share|improve this answer













                1. No

                2. No

                3. You can certainly do this and it is not uncommon to have views based on views. Whether it is a good idea, that's a matter of opinion.

                4. You cannot fully protect applications from underlying data model changes. If you introduce, remove, or change columns / columns in the data model, you must reflect them in the reports / applications, since the available content will change. If a table or column gets renamed, that can be hidden from the application through the use of views. However, if the rename is not that important so that you would reflect that in the report / application, then it begs the question why you need to rename the column.

                If your data structure changes so frequently, then an SQL-based product may not be the right thing for you, since SQL requires quite rigid definition of the data structure. You may have to consider a NoSql solution instead that allows greater flexibility in the database schema. However, data structure changes will affect the application / reporting even if you use a NoSql solution.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 21:45









                ShadowShadow

                26.6k9 gold badges30 silver badges47 bronze badges




                26.6k9 gold badges30 silver badges47 bronze badges


















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55346447%2fmysql-create-view-targeting-variable-table-name-columns-names%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현