Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Priyanka Dhingra
table without primary key column
November 9, 2012 9:57 PM
Answer

Priyanka Dhingra

Rank: Liferay Master

Posts: 501

Join Date: December 19, 2011

Recent Posts

I have a requirement to generate some tables without any primary column...
is that possible by service builder???
or any other way

Thanks in advance
Regards
Priyanka Dhingra
Hitoshi Ozawa
RE: table without primary key column
November 10, 2012 5:32 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

Can you give explanation on your situation?
I think you're not getting the fundamental design principle behind liferay.
Vishal Panchal
RE: table without primary key column
November 11, 2012 3:09 AM
Answer

Vishal Panchal

Rank: Expert

Posts: 277

Join Date: May 20, 2012

Recent Posts

HI Priyanka,

hitoshi is right.

But according to me a table without primary key is a simply useless thing.
Because we usually store the data in tables for retrieving them in future so for retrieving the data we need even a single unique column.
Hope it will help you emoticon.!

Thanks&Regards,
Vishal R. Panchal
Priyanka Dhingra
RE: table without primary key column
November 11, 2012 1:31 PM
Answer

Priyanka Dhingra

Rank: Liferay Master

Posts: 501

Join Date: December 19, 2011

Recent Posts

I have foriegn key in that table...would try to come up with the scenario in a diagram if still the case i mentioned doesnt satisfy
Priyanka Dhingra
RE: table without primary key column
November 14, 2012 10:31 PM
Answer

Priyanka Dhingra

Rank: Liferay Master

Posts: 501

Join Date: December 19, 2011

Recent Posts

Here is the sample diagram
in this in the state table we do not need a foriegn key.....

moreover , please suggest...if it is fine to use the
1<column name="if_service" type="Collection" mapping-key="id"
2            entity="activity" />

to establish the foriegn key reference relation??
Attachment

Attachments: diagram.JPG (22.7k)
Priyanka Dhingra
RE: table without primary key column
November 15, 2012 12:50 AM
Answer

Priyanka Dhingra

Rank: Liferay Master

Posts: 501

Join Date: December 19, 2011

Recent Posts

Hope I can get a quick answer emoticon
Priyanka Dhingra
RE: table without primary key column
November 16, 2012 7:06 AM
Answer

Priyanka Dhingra

Rank: Liferay Master

Posts: 501

Join Date: December 19, 2011

Recent Posts

Any help emoticon
David H Nebinger
RE: table without primary key column
November 16, 2012 10:02 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 6706

Join Date: September 1, 2006

Recent Posts

Yes, you should go an hire yourself a DBA because you clearly don't understand DB concepts.

If you did, you would realize that your PK on the table is actually ID_SERVICE and ID_ACTIVITY. Doesn't matter that they are foreign keys also, they are the values that will identify a unique row that represents a single relationship between the activity and service table.
Priyanka Dhingra
RE: table without primary key column
November 18, 2012 9:27 PM
Answer

Priyanka Dhingra

Rank: Liferay Master

Posts: 501

Join Date: December 19, 2011

Recent Posts

right emoticon
thanks David...
Ajeet Singh
RE: table without primary key column
November 19, 2012 3:39 AM
Answer

Ajeet Singh

Rank: New Member

Posts: 13

Join Date: March 27, 2012

Recent Posts

Hi Priyanka,

There should be a unique key in each table to fetch any row uniquely.

From the diagram posted by you, i understood that there might be many-to-many relationship between activity and service tables that's why a new table state has been created.

Now there are foreign key of activity table(id_activity) and service table(id_service) in the state table. Now here we should have a unique key in the state table and that unique key can be primary key or composite key ( id_activity + id_service).

So, i will say that in the current diagram you are not seeing the id ( i.e. primary key) so you might have the doubt about the primary key but here the design says that you should have composite key using id_activity and id_service.

Regards,
Ajeet Singh
Priyanka Dhingra
RE: table without primary key column
November 19, 2012 9:52 PM
Answer

Priyanka Dhingra

Rank: Liferay Master

Posts: 501

Join Date: December 19, 2011

Recent Posts

Thanks for replying Ajeet.. I hope now I can work with my service builder with this er diagram
Priyanka Dhingra
RE: table without primary key column
November 28, 2012 2:24 AM
Answer

Priyanka Dhingra

Rank: Liferay Master

Posts: 501

Join Date: December 19, 2011

Recent Posts

thanks ajeet for the hint...

and i got solution to define a composite key like following in my service builder
<column name="id_service" primary="true" type="long" />
<column name="id_activity" primary="true" type="long" />