Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Elijah "Ellie" Mangason
Liferay 6.1 what is classPk in the database?
August 7, 2012 9:39 AM
Answer

Elijah "Ellie" Mangason

Rank: Junior Member

Posts: 67

Join Date: May 14, 2012

Recent Posts

Is there documentation on the value of classPk in the databse? It appears as primary key in some tables, but then is cross referenced in others with a different meaning. Where can I get information on this, and the general design of the database? Any help or suggestions appreciated.
David H Nebinger
RE: Liferay 6.1 what is classPk in the database?
August 7, 2012 10:17 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7024

Join Date: September 1, 2006

Recent Posts

This is the only documentation you need to know: DO NOT LOOK IN THE DATABASE!

The database is not yours. It is not yours to modify, insert, update, or delete records on. It is not documented because you're not supposed to be in there.

Liferay provides APIs for accessing info in the database. Those are your only authorized points of entry.

Why is this important? Because the class pk column you see today might not be in the version that comes out tomorrow. If you use the APIs, that won't affect you (as long as the method signatures don't change emoticon).

Seriously, I'm not trying to be a jerk with this response. I'm trying to educate. Too many people have tried gleeming inforation about the data model only to end in failure.

That said, I'm sure you really want to know. Class PK is the primary key for some other record. The classNameId is a FK to the classname_ table which indicates the type of record (i.e. com.liferay.portal.model.User). Knowing the class name, you can then go to the corresponding table (in this case the user_ table) and infer the ClassPK is actually the user id.

This is used to allow some actual DB entity to be bound to some other DB entity w/o specifically creating separate many-to-many join tables w/ all of the various entities that may need a connection.
Elijah "Ellie" Mangason
RE: Liferay 6.1 what is classPk in the database?
August 9, 2012 10:03 AM
Answer

Elijah "Ellie" Mangason

Rank: Junior Member

Posts: 67

Join Date: May 14, 2012

Recent Posts

Many thanks for your erudite response! Actually, between the time I posted the question and the arrival of your reply, I figured it out. Don't worry, I am not doing any CRUD operations on the database directly as I understand the problems with that. Instead, I am using the Liferay APIs (UserLocalServiceUtil, TeamLocalServiceUtil, OrganizationLocalServiceUtil, etc.), which make more sense than trying to patch it together table by table.