Implementation of foreign key relationships in hive - hadoop

I was trying to create a hive table with a foreign key relationship with another table but I am facing errors with that.
Isn't it possible to implement a foreign key relationship in a hive table?

hive does not implement foreign keys refer to Hadoop Tutorials which describes as below:
Like any other SQL engines, we don't have any primary keys and foreign keys in Hive as hive is not meant to run complex relational queries. It's used to get data in easy and efficient manner. So while designing hive schema, we don't need to bother about selecting unique key etc. Also we don't need to bother about normalizing the set of data for efficiency.

Related

How to migrate Tarantool tables in the presence of foreign keys?

I want to migrate a Tarantool table to a different format. Currently (Tarantool 2.8), this must be done manually, by creating a new table, copying the data over, dropping the old table and renaming the new table to the old name. That also means dropping all foreign keys referencing the old table and creating new ones. But an unrelated limitation is that I can't create foreign keys on tables unless those tables are also empty.
Is there any way to solve this other than just not using foreign keys at all?
EDIT: I suppose I could emulate FKs with triggers. Are there any limitations with triggers that would make such emulation impossible?

Is a primary key necessary for greenplum database?

We know greenplum is a MPP data wirehouse, we will import data from mysql into it every day, the primary key may conflict from different source. I am designing the schema, I am not sure:
Is primary key required for each table?
From offical docs, the primary key is used for partition by default, but I can specify another key to partition, is there any other reason that I have to set a primary key?
No, a primary key is not needed in Greenplum. It will actually slow down your loading performance, take up storage space, and likely not be used for any queries.
The distribution key is often times set to be the logical primary key of a table but without an actual primary key created. The distribution key should be a high cardinality column like the primary key, which helps distribute the data evenly across the segments.
And you can specify another key for the distribution key too.
Lastly, I wouldn't call this a way to "partition" the data because partitioning is something else in Greenplum. Partitioning is akin to Oracle or SQL Server partitioning with the query optimizer eliminating partitions based on the conditions (where month = 1) in the query.

I have a MYSQL table creation query containing the following constraint KEY `ix_email_address` (`address`) . How can I implement this in hive?

KEY ix_email_address (address) how to implement the MySQL constraint in Hive ?
Hive doesn't contain any primary/foreign key notions. You need to find another way to implement those constraints. Look here.

Foreign key limitations

I am wondering if a PL/SQL (oracle) table can carry three foreign keys? thanks in advance if any one can help me in this regard.
There is no explicit limit on the number of foreign keys on a table. However, there is a limit of 1000 columns per table, so that probably constitutes a practical limit.
Here is a SQL Fiddle which creates a toy table with five foreign keys.
There is not limit on foreign keys use except logic which based behind use of foreign keys, and if one table needs too much foreign keys, which is not logic wise, and database design suffers in such scenario.
As well as 1000-column constraint of oracle tables and pl/sql procedures also have limit in code.

Does Oracle automatically create a secondary index for FOREIGN KEY columns?

I'm currenly developing on Oracle. I have several tables for which I defined FOREIGN KEY constraints. I have already read this SQL Server-oriented and this MySQL-oriented questions but I could find none about Oracle.
So the question is always the same: in order to optimize query performance, for those columns for which I create a FOREIGN KEY constraint, do I also have to create an explicit secondary index? Doesn't Oracle automatically create an index on FOREIGN KEYed columns to boost performances during JOINs?
I usually perform queries in which the WHERE clause compare against those columns.
No, Oracle doesn't automatically create indexes on foreign key columns, even though in 99% of cases you probably should. Apart from helping with queries, the index also improves the performance of delete statements on the parent table.

Resources