Database & SQL

Moderators: None (Apply to moderate this forum)
Number of threads: 1174
Number of posts: 2221

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Relational Database: Union Compatibility Question Posted by tonyosborne on 30 Nov 2004 at 10:18 AM

Hi,

According to one reference, the union compatibility is defined as
such:
(1)the two relations have the same degree n (number of attributes) ,
and (2) domain (Ai)= domain (Bi) for 1=<i<=n, where domain stands for
data type.

In other reference, it is stated that two relations are union
compatibles if they have the same degree and the *same attribute
names* and domains. The *order of attributes is immaterial*.

which one is the fully correct?


I don't believe that the two relations should have the same attribute
names as stated in the 2nd definition , but i understand that each
pair of the two relations attributes should be of the same domain.
what about the order of attributes? Has it to be the same?

I understabd from the first definition that the attributes domains
order should be the same unlike in the second definition. which one is
correct?

The relational database is based on the concept of sets where the
order of rows and columns is not important. This tends to support
definition 2. However, if we assume that each relation has two
attributes of the same domain (eg 10 char), how the Union operator can
choose between them when mapping the attributes of relation A and B,
having different relative attributes orders


for instance Relation A schema is Fname,LName, City , Age;
the second Relation B schema is City1,FName1,Age1,LName1

where Fname,Fname1,LName,LName1 is restricted to be of 10 chars

A Union B=?


Another question, can the foreign key be NULL? are all the DBMS case
(un)sensistive?



<:> thank you <:>

Report
Re: Relational Database: Union Compatibility Question Posted by infidel on 6 Dec 2004 at 12:18 PM
: According to one reference, the union compatibility is defined as
: such:
: (1)the two relations have the same degree n (number of attributes) ,
: and (2) domain (Ai)= domain (Bi) for 1=<i<=n, where domain stands for
: data type.
:
: In other reference, it is stated that two relations are union
: compatibles if they have the same degree and the *same attribute
: names* and domains. The *order of attributes is immaterial*.
:
: which one is the fully correct?

I don't know. I would think the types are more important than the names.

: I don't believe that the two relations should have the same attribute
: names as stated in the 2nd definition , but i understand that each
: pair of the two relations attributes should be of the same domain.
: what about the order of attributes? Has it to be the same?
:
: I understabd from the first definition that the attributes domains
: order should be the same unlike in the second definition. which one is
: correct?

Again, I would lean towards the data types being consistent. I don't think UNION has much to do with relations as with selected values. I see it as merging together two otherwise unrelated queries. If you don't have the same number of values, or if the types of values in corresponding positions are inconsistent, the DBMS can't know how to merge the two sets into one set.

: The relational database is based on the concept of sets where the
: order of rows and columns is not important. This tends to support
: definition 2. However, if we assume that each relation has two
: attributes of the same domain (eg 10 char), how the Union operator can
: choose between them when mapping the attributes of relation A and B,
: having different relative attributes orders

Again, I do not believe you are unioning relations, but are instead unioning query results from those relations. Query results are not ordered row-wise, but they are ordered column-wise.

: Another question, can the foreign key be NULL? are all the DBMS case
: (un)sensistive?

I believe a foreign key can be NULL (meaning the record is an orphan).

I believe SQL is defined as case-insensitive.


infidel

$ select * from users where clue > 0
no rows returned





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.