Can a Join happen with same attribute names, but different domains?
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:
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
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.
add a comment |
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:
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
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
add a comment |
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:
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
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:
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
join relational-algebra
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Jan 27 '18 at 17:19
clifton_hclifton_h
51237
51237
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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