Can a Join happen with same attribute names, but different domains?












0














Problem



When doing any sort of Join all common attributes are listed under one column in one way or another. However, I have not been able to find a source that deal with columns of the same name, but with different domains.



Put in a visual perspective, I am taking about columns like the case below:



enter image description hereenter image description here



The domain is different because one B column is numbers but the other is letters.



Question



Is a Join possible with attributes of the same name but different domains?










share|improve this question














bumped to the homepage by Community 47 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1




    Yes - as long as you're careful to qualify which table you're referring to!
    – Vérace
    Jan 27 '18 at 16:25










  • But in the resulting relation of a Join, attributes of the same name are listed under the same column. Yes you can rename the column, but I'm talking about in the case where you are not supposed to rename either column.
    – isakbob
    Jan 27 '18 at 16:36












  • Could you show us what you want with data?
    – Evan Carroll
    2 mins ago
















0














Problem



When doing any sort of Join all common attributes are listed under one column in one way or another. However, I have not been able to find a source that deal with columns of the same name, but with different domains.



Put in a visual perspective, I am taking about columns like the case below:



enter image description hereenter image description here



The domain is different because one B column is numbers but the other is letters.



Question



Is a Join possible with attributes of the same name but different domains?










share|improve this question














bumped to the homepage by Community 47 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1




    Yes - as long as you're careful to qualify which table you're referring to!
    – Vérace
    Jan 27 '18 at 16:25










  • But in the resulting relation of a Join, attributes of the same name are listed under the same column. Yes you can rename the column, but I'm talking about in the case where you are not supposed to rename either column.
    – isakbob
    Jan 27 '18 at 16:36












  • Could you show us what you want with data?
    – Evan Carroll
    2 mins ago














0












0








0







Problem



When doing any sort of Join all common attributes are listed under one column in one way or another. However, I have not been able to find a source that deal with columns of the same name, but with different domains.



Put in a visual perspective, I am taking about columns like the case below:



enter image description hereenter image description here



The domain is different because one B column is numbers but the other is letters.



Question



Is a Join possible with attributes of the same name but different domains?










share|improve this question













Problem



When doing any sort of Join all common attributes are listed under one column in one way or another. However, I have not been able to find a source that deal with columns of the same name, but with different domains.



Put in a visual perspective, I am taking about columns like the case below:



enter image description hereenter image description here



The domain is different because one B column is numbers but the other is letters.



Question



Is a Join possible with attributes of the same name but different domains?







join relational-algebra






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 27 '18 at 16:23









isakbobisakbob

1629




1629





bumped to the homepage by Community 47 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 47 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.










  • 1




    Yes - as long as you're careful to qualify which table you're referring to!
    – Vérace
    Jan 27 '18 at 16:25










  • But in the resulting relation of a Join, attributes of the same name are listed under the same column. Yes you can rename the column, but I'm talking about in the case where you are not supposed to rename either column.
    – isakbob
    Jan 27 '18 at 16:36












  • Could you show us what you want with data?
    – Evan Carroll
    2 mins ago














  • 1




    Yes - as long as you're careful to qualify which table you're referring to!
    – Vérace
    Jan 27 '18 at 16:25










  • But in the resulting relation of a Join, attributes of the same name are listed under the same column. Yes you can rename the column, but I'm talking about in the case where you are not supposed to rename either column.
    – isakbob
    Jan 27 '18 at 16:36












  • Could you show us what you want with data?
    – Evan Carroll
    2 mins ago








1




1




Yes - as long as you're careful to qualify which table you're referring to!
– Vérace
Jan 27 '18 at 16:25




Yes - as long as you're careful to qualify which table you're referring to!
– Vérace
Jan 27 '18 at 16:25












But in the resulting relation of a Join, attributes of the same name are listed under the same column. Yes you can rename the column, but I'm talking about in the case where you are not supposed to rename either column.
– isakbob
Jan 27 '18 at 16:36






But in the resulting relation of a Join, attributes of the same name are listed under the same column. Yes you can rename the column, but I'm talking about in the case where you are not supposed to rename either column.
– isakbob
Jan 27 '18 at 16:36














Could you show us what you want with data?
– Evan Carroll
2 mins ago




Could you show us what you want with data?
– Evan Carroll
2 mins ago










1 Answer
1






active

oldest

votes


















0














I think you are being misled by your terminology.



SQL is a standard that has the following schematics




  • Schema

  • Table

  • Column

  • Attribute


*Oracle does not have separate databases in an Instance. schemas are tied to a user.



SQL is a 4th generation language that separates the need to know where to query an object to high, almost human language-style programming



When you write a Query in SQL, the compiler (called the SQL Optimizer) translates this into machine-level language and retrieves your data. It is therefore highly dependent on the Optimizer to correctly retrieve the data how it thinks is best.



What this means is that your SQL is nothing more than meaningful suggestions to the Optimizer. All you need to know is what the Structures’ names are, not where or how to grab it.



SQL has hints and Operators that help the Optimizer to pick the right datasets, but it is the Optimizer that chooses the ORDER of the Query to parse first.



Thus, you are writing Logical queries. If two tables are joined, it is your responsibility to help the Optimizer by specifically calling out the columns that can be joined.



Even if the attributes are not the same, the Optimizer is fully agile enough to know how to translate on the fly these values. For example, a VARCHAR type value of ‘13’ is still rather similar to a tinyint, integer, numeric Value, so the Optimizer will Implicitly convert these columns into the same data type!



The following example is in TSQL:



CREATE TABLE TableA (col_A int, col_B varchar(24) )
CREATE TABLE TableB (col_A varchar(24), col_B int)
INSERT INTO TableA (col_A, col_B)
VALUES (1, ‘My Value’)
INSERT INTO TableB (col_A, col_B)
VALUES (‘Not my Value’, 1)

SELECT A.Col_B
FROM TableA AS A
INNER JOIN TableB AS B ON A.Col_A = B.col_B


Notice we used an alias to help the optimizer know what we mean by the join and what we mean by which column to return.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "182"
    };
    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: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2fdba.stackexchange.com%2fquestions%2f196413%2fcan-a-join-happen-with-same-attribute-names-but-different-domains%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









    0














    I think you are being misled by your terminology.



    SQL is a standard that has the following schematics




    • Schema

    • Table

    • Column

    • Attribute


    *Oracle does not have separate databases in an Instance. schemas are tied to a user.



    SQL is a 4th generation language that separates the need to know where to query an object to high, almost human language-style programming



    When you write a Query in SQL, the compiler (called the SQL Optimizer) translates this into machine-level language and retrieves your data. It is therefore highly dependent on the Optimizer to correctly retrieve the data how it thinks is best.



    What this means is that your SQL is nothing more than meaningful suggestions to the Optimizer. All you need to know is what the Structures’ names are, not where or how to grab it.



    SQL has hints and Operators that help the Optimizer to pick the right datasets, but it is the Optimizer that chooses the ORDER of the Query to parse first.



    Thus, you are writing Logical queries. If two tables are joined, it is your responsibility to help the Optimizer by specifically calling out the columns that can be joined.



    Even if the attributes are not the same, the Optimizer is fully agile enough to know how to translate on the fly these values. For example, a VARCHAR type value of ‘13’ is still rather similar to a tinyint, integer, numeric Value, so the Optimizer will Implicitly convert these columns into the same data type!



    The following example is in TSQL:



    CREATE TABLE TableA (col_A int, col_B varchar(24) )
    CREATE TABLE TableB (col_A varchar(24), col_B int)
    INSERT INTO TableA (col_A, col_B)
    VALUES (1, ‘My Value’)
    INSERT INTO TableB (col_A, col_B)
    VALUES (‘Not my Value’, 1)

    SELECT A.Col_B
    FROM TableA AS A
    INNER JOIN TableB AS B ON A.Col_A = B.col_B


    Notice we used an alias to help the optimizer know what we mean by the join and what we mean by which column to return.






    share|improve this answer


























      0














      I think you are being misled by your terminology.



      SQL is a standard that has the following schematics




      • Schema

      • Table

      • Column

      • Attribute


      *Oracle does not have separate databases in an Instance. schemas are tied to a user.



      SQL is a 4th generation language that separates the need to know where to query an object to high, almost human language-style programming



      When you write a Query in SQL, the compiler (called the SQL Optimizer) translates this into machine-level language and retrieves your data. It is therefore highly dependent on the Optimizer to correctly retrieve the data how it thinks is best.



      What this means is that your SQL is nothing more than meaningful suggestions to the Optimizer. All you need to know is what the Structures’ names are, not where or how to grab it.



      SQL has hints and Operators that help the Optimizer to pick the right datasets, but it is the Optimizer that chooses the ORDER of the Query to parse first.



      Thus, you are writing Logical queries. If two tables are joined, it is your responsibility to help the Optimizer by specifically calling out the columns that can be joined.



      Even if the attributes are not the same, the Optimizer is fully agile enough to know how to translate on the fly these values. For example, a VARCHAR type value of ‘13’ is still rather similar to a tinyint, integer, numeric Value, so the Optimizer will Implicitly convert these columns into the same data type!



      The following example is in TSQL:



      CREATE TABLE TableA (col_A int, col_B varchar(24) )
      CREATE TABLE TableB (col_A varchar(24), col_B int)
      INSERT INTO TableA (col_A, col_B)
      VALUES (1, ‘My Value’)
      INSERT INTO TableB (col_A, col_B)
      VALUES (‘Not my Value’, 1)

      SELECT A.Col_B
      FROM TableA AS A
      INNER JOIN TableB AS B ON A.Col_A = B.col_B


      Notice we used an alias to help the optimizer know what we mean by the join and what we mean by which column to return.






      share|improve this answer
























        0












        0








        0






        I think you are being misled by your terminology.



        SQL is a standard that has the following schematics




        • Schema

        • Table

        • Column

        • Attribute


        *Oracle does not have separate databases in an Instance. schemas are tied to a user.



        SQL is a 4th generation language that separates the need to know where to query an object to high, almost human language-style programming



        When you write a Query in SQL, the compiler (called the SQL Optimizer) translates this into machine-level language and retrieves your data. It is therefore highly dependent on the Optimizer to correctly retrieve the data how it thinks is best.



        What this means is that your SQL is nothing more than meaningful suggestions to the Optimizer. All you need to know is what the Structures’ names are, not where or how to grab it.



        SQL has hints and Operators that help the Optimizer to pick the right datasets, but it is the Optimizer that chooses the ORDER of the Query to parse first.



        Thus, you are writing Logical queries. If two tables are joined, it is your responsibility to help the Optimizer by specifically calling out the columns that can be joined.



        Even if the attributes are not the same, the Optimizer is fully agile enough to know how to translate on the fly these values. For example, a VARCHAR type value of ‘13’ is still rather similar to a tinyint, integer, numeric Value, so the Optimizer will Implicitly convert these columns into the same data type!



        The following example is in TSQL:



        CREATE TABLE TableA (col_A int, col_B varchar(24) )
        CREATE TABLE TableB (col_A varchar(24), col_B int)
        INSERT INTO TableA (col_A, col_B)
        VALUES (1, ‘My Value’)
        INSERT INTO TableB (col_A, col_B)
        VALUES (‘Not my Value’, 1)

        SELECT A.Col_B
        FROM TableA AS A
        INNER JOIN TableB AS B ON A.Col_A = B.col_B


        Notice we used an alias to help the optimizer know what we mean by the join and what we mean by which column to return.






        share|improve this answer












        I think you are being misled by your terminology.



        SQL is a standard that has the following schematics




        • Schema

        • Table

        • Column

        • Attribute


        *Oracle does not have separate databases in an Instance. schemas are tied to a user.



        SQL is a 4th generation language that separates the need to know where to query an object to high, almost human language-style programming



        When you write a Query in SQL, the compiler (called the SQL Optimizer) translates this into machine-level language and retrieves your data. It is therefore highly dependent on the Optimizer to correctly retrieve the data how it thinks is best.



        What this means is that your SQL is nothing more than meaningful suggestions to the Optimizer. All you need to know is what the Structures’ names are, not where or how to grab it.



        SQL has hints and Operators that help the Optimizer to pick the right datasets, but it is the Optimizer that chooses the ORDER of the Query to parse first.



        Thus, you are writing Logical queries. If two tables are joined, it is your responsibility to help the Optimizer by specifically calling out the columns that can be joined.



        Even if the attributes are not the same, the Optimizer is fully agile enough to know how to translate on the fly these values. For example, a VARCHAR type value of ‘13’ is still rather similar to a tinyint, integer, numeric Value, so the Optimizer will Implicitly convert these columns into the same data type!



        The following example is in TSQL:



        CREATE TABLE TableA (col_A int, col_B varchar(24) )
        CREATE TABLE TableB (col_A varchar(24), col_B int)
        INSERT INTO TableA (col_A, col_B)
        VALUES (1, ‘My Value’)
        INSERT INTO TableB (col_A, col_B)
        VALUES (‘Not my Value’, 1)

        SELECT A.Col_B
        FROM TableA AS A
        INNER JOIN TableB AS B ON A.Col_A = B.col_B


        Notice we used an alias to help the optimizer know what we mean by the join and what we mean by which column to return.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 27 '18 at 17:19









        clifton_hclifton_h

        51237




        51237






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Database Administrators Stack Exchange!


            • 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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2fdba.stackexchange.com%2fquestions%2f196413%2fcan-a-join-happen-with-same-attribute-names-but-different-domains%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

            Liste der Baudenkmale in Friedland (Mecklenburg)

            Single-Malt-Whisky

            Czorneboh