How to create a childtable from a table having a column with multiple values. how to make new table in spring - spring

How to create a childtable from a table having a column with multiple value separted by commas
Need to create a new table with foreign key and that particular value in spring mvc

Related

how to store foriegn key ids in new table in mvc in many to many relationship

the problem is that i have made three tables and first two table's primary keys are declared as foreign keys in the third table. now i want to store data in the third table but the problem is that no ids are being passsed to the foreign Key values thats why i am getting errors
as you can see i have shown to drop down lists, one for student and second for courses but when i try to register the record it is not getting ids of primary keys which are declared as foreign keys in the new table

Can I add a NOT NULL constraint to a CockroachDB column?

I want to add NOT NULL to a column, but it looks like ADD CONSTRAINT doesn’t support it. How can I add the constraint?
Cockroach does not currently allow adding these constraints to an existing table.
One workaround is to create a new table with the schema you want to use (including the NOT NULL constraint), and then migrate the data to the new table using INSERT...SELECT.
Here’s an example:
CREATE TABLE tbl2 (id INT PRIMARY KEY, col_a INT NOT NULL);
INSERT INTO tbl2 SELECT * FROM tbl1;
This assumes that tbl1 has the same number of columns with the same types and doesn’t have any NULL values in its version of col_a.
The downside of this is that it has to copy all the table data, so it is not ideal on large tables.
Another workaround would be to add a new column, with the NOT NULL constraint (which implies it would also require a DEFAULT), then use an UPDATE to set its value from the existing column, then rename the new column and drop the old one.

How different is this to creating a primary key on a column in hive?

I read that we cannot create a primary key on a column in a Hive table. But I saw the below DDL in some other place and executed it. It worked without any problem.
create table prim(id int, name char(30))
TBLPROPERTIES("PRIMARY KEY"="id");
After this I executed "describe formatted prim" and got to see that a key is created on the column ID
Table Parameters:
PRIMARY KEY id
I inserted two records with same ID number into the table.
insert into prim values(1,'ABCD');
insert into prim values(2,'EFGH');
Both the records were inserted into the table. What baffles me is that we cannot give the PRIMARY KEY in the create statement which I can understand, but when given in TBLPROPERTIES("PRIMARY KEY"="id") how different is it to the primary key in RDBMS.
PRIMARY KEY in TBLPROPERTIES is for metadata reference to preserve column significance. It does not apply any constrain on that column. This can be used as a reference from design perspective.

Can we create a function based primary key in Oracle 10?

There is a requirement in our application to create the unique primary key which depend on the value of another unique column (ERROR_CODE). But our application is in a geo active active environment (have several active databases which are synchronized using another program).
Therefore even-though we have a unique constraint on this ERROR_CODE field, there is a possibility that each database has a row with a different PK for the same ERROR_CODE. During the database synchronization, this is a problem, because there are some child tables which has the PK stored in one DB and other rows contain the PK stored in other DB. Because of the unique constraint of ERROR_CODE, sync process cannot move both rows to each database (which is also not a good thing to do).
So there is a suggestion to use the hash of the ERROR_CODE field as the PK value.
I would like to know whether we can define a function based Primary key in oracle?
If PK field is "ID",
"ID" should be equal to ora_has(ERROR_CODE).
Is it possible to define the primary key like that in oracle?
In Oracle 10 you cannot do this, but in Oracle 11 you can. You have to create a virtual column, such columns can be used also as primary key:
ALTER TABLE MY_TABLE ADD (ID NUMBER GENERATED ALWAYS AS (ora_has(ERROR_CODE)) VIRTUAL);
ALTER TABLE MY_TABLE ADD CONSTRAINT t_test_pk PRIMARY KEY (ID) USING INDEX;

Wavemaker Service Variable HQL update foreign key column

I have two tables employee, department with a one to many relationship such that a column name 'depRefID' in employee references the primary key of the 'department' table.
I have a dojogrid that fetched data from employee table via a Service variable and a select menu that lists the department names.
I've setup an onchange function on the select menu that, would ideally loop each selected row in the employee table and change its foreign key to the one selected via the select widget.
I'm trying to use a separate service variable to update "employee" table using and update query.
How can I reference or access the foreign key 'depRefID' in HQl as directly referencing it throws an exception.

Resources