Database Info

Database Info

Table of Contents [show]1 Custom Tables2 Other Tables Used by LearnDash3 Data of Deleted Users4 Additional Quiz Tables4.1 Was this article helpful to you?
Custom Tables
All LearnDash data is stored within the same database used to run WordPress. LearnDash does not store or connect to any external data sources to retrieve or store data about users, courses, quizzes, etc.
LearnDash has two database tables to contain the users Course and Quiz progress details.
The first table is wp_learndash_user_activity which works similar to the 『wp_posts』 table to record the activity type course, lesson, topic or quiz as well as the started and completed timestamps. This table is keyed by the 『user_id』 and』 post_id』.
The second table is wp_learndash_user_activity_meta which works like the 『wp_postmeta』. This table contains meta information related to the activity record in the main 『wp_learndash_user_activity』.
There is a referenced activity_id field to link the main activity row to the activity meta rows. This meta information is the same items stored into the user meta array elements and will be keys like 『steps_total』, 『score』, 『points』, etc. (basically key/value pairs of meta data needed to be stored as part of the activity record).
The process for populating these tables works in addition to the existing course and quiz progress. This means that when a user completes a lesson, the first part of the transaction will update the existing user meta array item. Afterwards, a secondary step will update the activity database tables. Please note that in future versions of LearnDash we will remove the dependence on the user meta array completely.
The database table details (schemas) are as follows:
CREATE TABLE `wp_learndash_user_activity` (
`activity_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`post_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`activity_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`activity_status` tinyint(1) unsigned DEFAULT '0',
`activity_started` int(11) unsigned DEFAULT NULL,
`activity_completed` int(11) unsigned DEFAULT NULL,
`activity_updated` int(11) unsigned DEFAULT NULL,
PRIMARY KEY (`activity_id`),
KEY `user_id` (`user_id`),
KEY `post_id` (`post_id`),
KEY `activity_status` (`activity_status`),
KEY `activity_type` (`activity_type`),
KEY `activity_started` (`activity_started`),
KEY `activity_completed` (`activity_completed`),
KEY `activity_updated` (`activity_updated`)
)
CREATE TABLE `wp_learndash_user_activity_meta` (
`activity_meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`activity_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`activity_meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`activity_meta_value` mediumtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`activity_meta_id`),
KEY `activity_id` (`activity_id`),
KEY `activity_meta_key` (`activity_meta_key`(191))
)
Other Tables Used by LearnDash

wp_postmeta
wp_posts
wp_usermeta
wp_users

Data of Deleted Users
When a user is deleted via WordPress it also deletes of the user』s meta data.
Deleting a user removes the Assignment and Essay custom post types created by that user.
Quiz related statistics stored into the table wp_wp_pro_quiz_statistic and wp_wp_pro_quiz_statistic_ref are also remove when the user is deleted.
Additional Quiz Tables

wp_wp_pro_quiz_category
wp_wp_pro_quiz_form
wp_wp_pro_quiz_lock
wp_wp_pro_quiz_master
wp_wp_pro_quiz_prerequisite
wp_wp_pro_quiz_question
wp_wp_pro_quiz_template
wp_wp_pro_quiz_toplist

Was this article helpful to you?

Yes

No

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注