added database tables outlining "community" objects and initial interface
definition for community and community service
This commit is contained in:
@@ -30,37 +30,37 @@ USE venice;
|
||||
# The "namespace cache" table, used to map string namespaces (used in the code) to integer IDs
|
||||
# (used in the database).
|
||||
CREATE TABLE namespaces (
|
||||
nsid INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
namespace VARCHAR(255) BINARY NOT NULL,
|
||||
nsid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # namespace ID
|
||||
namespace VARCHAR(255) BINARY NOT NULL, # the actual namespace
|
||||
UNIQUE INDEX on_namespace (namespace)
|
||||
);
|
||||
|
||||
# The global properties table.
|
||||
CREATE TABLE globalprop (
|
||||
nsid INT NOT NULL,
|
||||
prop_name VARCHAR(255) BINARY NOT NULL,
|
||||
prop_value VARCHAR(255),
|
||||
nsid INT NOT NULL, # namespace ID of property
|
||||
prop_name VARCHAR(255) BINARY NOT NULL, # name of the property
|
||||
prop_value VARCHAR(255), # property value
|
||||
PRIMARY KEY (nsid, prop_name)
|
||||
);
|
||||
|
||||
# The global "blocks" table, used to store fragments of text/HTML for later use.
|
||||
CREATE TABLE globalblock (
|
||||
nsid INT NOT NULL,
|
||||
block_name VARCHAR(255) BINARY NOT NULL,
|
||||
block TEXT,
|
||||
nsid INT NOT NULL, # namespace ID of block
|
||||
block_name VARCHAR(255) BINARY NOT NULL, # name of block
|
||||
block TEXT, # actual block (64K text)
|
||||
PRIMARY KEY (nsid, block_name)
|
||||
);
|
||||
|
||||
# The main user information table.
|
||||
CREATE TABLE users (
|
||||
uid INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
username VARCHAR(64) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
is_anon TINYINT DEFAULT 0,
|
||||
locked TINYINT DEFAULT 0,
|
||||
nospam TINYINT DEFAULT 0,
|
||||
created DATETIME NOT NULL,
|
||||
last_accessed DATETIME,
|
||||
uid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # user ID
|
||||
username VARCHAR(64) NOT NULL, # user name
|
||||
email VARCHAR(255) NOT NULL, # E-mail address
|
||||
is_anon TINYINT DEFAULT 0, # is this the "anonymous" user?
|
||||
locked TINYINT DEFAULT 0, # is this user account locked?
|
||||
nospam TINYINT DEFAULT 0, # if 1, do not include this user in any mass mailings
|
||||
created DATETIME NOT NULL, # date user was created
|
||||
last_accessed DATETIME, # date user last logged in
|
||||
UNIQUE INDEX on_username (username)
|
||||
);
|
||||
|
||||
@@ -68,117 +68,115 @@ CREATE TABLE users (
|
||||
# and name, and provide "source data" to allow multiple sources for the same type of
|
||||
# authentication (such as browser cookies for multiple browsers).
|
||||
CREATE TABLE userauth (
|
||||
uid INT NOT NULL,
|
||||
nsid INT NOT NULL,
|
||||
method VARCHAR(255) BINARY NOT NULL,
|
||||
source_data VARCHAR(255),
|
||||
auth_data VARCHAR(255),
|
||||
uid INT NOT NULL, # user ID
|
||||
nsid INT NOT NULL, # namespace ID of authentication method
|
||||
method VARCHAR(255) BINARY NOT NULL, # name of authentication method
|
||||
source_data VARCHAR(255), # source data for authentication method
|
||||
auth_data VARCHAR(255), # authentication data
|
||||
PRIMARY KEY (uid, nsid, method)
|
||||
);
|
||||
|
||||
# The user properties table.
|
||||
CREATE TABLE userprop (
|
||||
uid INT NOT NULL,
|
||||
nsid INT NOT NULL,
|
||||
prop_name VARCHAR(255) BINARY NOT NULL,
|
||||
prop_value VARCHAR(255),
|
||||
uid INT NOT NULL, # user ID
|
||||
nsid INT NOT NULL, # namespace ID of property
|
||||
prop_name VARCHAR(255) BINARY NOT NULL, # name of property
|
||||
prop_value VARCHAR(255), # property value
|
||||
PRIMARY KEY (uid, nsid, prop_name)
|
||||
);
|
||||
|
||||
# The groups table.
|
||||
CREATE TABLE groups (
|
||||
gid INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
groupname VARCHAR(64) NOT NULL,
|
||||
gaclid INT NOT NULL DEFAULT -1,
|
||||
gid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # group ID
|
||||
groupname VARCHAR(64) NOT NULL, # name of group
|
||||
gaclid INT NOT NULL DEFAULT -1, # ACL ID for the group
|
||||
UNIQUE INDEX on_groupname (groupname)
|
||||
);
|
||||
|
||||
# The group membership table.
|
||||
CREATE TABLE groupmembers (
|
||||
gid INT NOT NULL,
|
||||
uid INT NOT NULL,
|
||||
gid INT NOT NULL, # ID of group
|
||||
uid INT NOT NULL, # ID of user that is a member
|
||||
PRIMARY KEY (gid, uid),
|
||||
UNIQUE INDEX reverse_index (uid, gid)
|
||||
);
|
||||
|
||||
# The group properties table.
|
||||
CREATE TABLE groupprop (
|
||||
gid INT NOT NULL,
|
||||
nsid INT NOT NULL,
|
||||
prop_name VARCHAR(255) BINARY NOT NULL,
|
||||
prop_value VARCHAR(255),
|
||||
gid INT NOT NULL, # ID of group
|
||||
nsid INT NOT NULL, # namespace ID for property
|
||||
prop_name VARCHAR(255) BINARY NOT NULL, # name of property
|
||||
prop_value VARCHAR(255), # property value
|
||||
PRIMARY KEY (gid, nsid, prop_name)
|
||||
);
|
||||
|
||||
# The main ACL table. Each ACL has a numeric ID, a name, an unordered collection of owners (which may
|
||||
# be groups or users), and an ordered collection of entries (ACEs).
|
||||
CREATE TABLE acl (
|
||||
aclid INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
aclname VARCHAR(255) NOT NULL,
|
||||
aclid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # ID of the ACL
|
||||
aclname VARCHAR(255) NOT NULL, # name of the ACL
|
||||
INDEX on_name (aclname)
|
||||
);
|
||||
|
||||
# The table of owners for ACLs. Each ACL has one or more owners.
|
||||
# Flags Bit 0: 0=user, 1=group
|
||||
CREATE TABLE aclowner (
|
||||
aclid INT NOT NULL,
|
||||
ownerid INT NOT NULL,
|
||||
flags TINYINT NOT NULL,
|
||||
aclid INT NOT NULL, # ID of the ACL
|
||||
ownerid INT NOT NULL, # ID of the owner
|
||||
flags TINYINT NOT NULL, # Flags Bit 0: 0=user, 1=group
|
||||
INDEX on_acl (aclid)
|
||||
);
|
||||
|
||||
# The table mapping ACLs to ACEs. Each ACL has zero or more ACEs.
|
||||
CREATE TABLE acldata (
|
||||
aclid INT NOT NULL,
|
||||
seq INT NOT NULL,
|
||||
aceid INT NOT NULL,
|
||||
aclid INT NOT NULL, # ID of the ACL
|
||||
seq INT NOT NULL, # sequence of this ACE
|
||||
aceid INT NOT NULL, # ID of the corresponding ACE
|
||||
PRIMARY KEY (aclid, seq)
|
||||
);
|
||||
|
||||
# The main ACE table. Each ACE has a numeric ID, a principal reference (which may be a user or
|
||||
# group ID), a "negative" flag, and an unordered collection of permissions.
|
||||
# Flags Bit 0: 0=user, 1=group
|
||||
# Flags Bit 4: 0=positive ACE, 1=negative ACE
|
||||
CREATE TABLE ace (
|
||||
aceid INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
pri INT,
|
||||
flags TINYINT NOT NULL DEFAULT 0
|
||||
aceid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # ID of this ACE
|
||||
pri INT, # Principal reference
|
||||
flags TINYINT NOT NULL DEFAULT 0 # Flags Bit 0: 0=user, 1=group
|
||||
# Flags Bit 4: 0=positive ACE, 1=negative ACE
|
||||
);
|
||||
|
||||
# The table mapping permissions into ACEs. Permissions are identified by namespace and name.
|
||||
CREATE TABLE acedata (
|
||||
aceid INT NOT NULL,
|
||||
perm_nsid INT NOT NULL,
|
||||
perm_name VARCHAR(255) BINARY NOT NULL,
|
||||
aceid INT NOT NULL, # ID of this ACE
|
||||
perm_nsid INT NOT NULL, # namespace ID of permission
|
||||
perm_name VARCHAR(255) BINARY NOT NULL, # name of permission
|
||||
INDEX on_ace (aceid)
|
||||
);
|
||||
|
||||
# Global security data table.
|
||||
# Global security data table. This table has only one row.
|
||||
CREATE TABLE globalsec (
|
||||
admin_uid INT NOT NULL,
|
||||
admin_gid INT NOT NULL,
|
||||
global_aclid INT NOT NULL,
|
||||
alluser_gid INT NOT NULL,
|
||||
verified_gid INT NOT NULL
|
||||
admin_uid INT NOT NULL, # administrator UID
|
||||
admin_gid INT NOT NULL, # GID of administrators group
|
||||
global_aclid INT NOT NULL, # ACLID of global ACL
|
||||
alluser_gid INT NOT NULL, # GID of "all users" GID
|
||||
verified_gid INT NOT NULL # GID of "verified users" GID
|
||||
);
|
||||
|
||||
# The audit information table. Each audit "event" can have up to 8 properties defined with it,
|
||||
# which are serialized as other "properties."
|
||||
CREATE TABLE audit (
|
||||
record BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
on_date DATETIME NOT NULL,
|
||||
event INT NOT NULL,
|
||||
uid INT NOT NULL,
|
||||
subid INT NOT NULL DEFAULT 0,
|
||||
ip VARCHAR(48),
|
||||
prop0 VARCHAR(255),
|
||||
prop1 VARCHAR(255),
|
||||
prop2 VARCHAR(255),
|
||||
prop3 VARCHAR(255),
|
||||
prop4 VARCHAR(255),
|
||||
prop5 VARCHAR(255),
|
||||
prop6 VARCHAR(255),
|
||||
prop7 VARCHAR(255),
|
||||
record BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, # audit record ID
|
||||
on_date DATETIME NOT NULL, # date stamp of audit record
|
||||
event INT NOT NULL, # event ID
|
||||
uid INT NOT NULL, # user ID of responsible user
|
||||
subid INT NOT NULL DEFAULT 0, # "sub ID" (often community ID)
|
||||
ip VARCHAR(48), # IP address of source
|
||||
prop0 VARCHAR(255), # event property
|
||||
prop1 VARCHAR(255), # event property
|
||||
prop2 VARCHAR(255), # event property
|
||||
prop3 VARCHAR(255), # event property
|
||||
prop4 VARCHAR(255), # event property
|
||||
prop5 VARCHAR(255), # event property
|
||||
prop6 VARCHAR(255), # event property
|
||||
prop7 VARCHAR(255), # event property
|
||||
INDEX by_date (on_date),
|
||||
INDEX sub_view (subid, on_date)
|
||||
);
|
||||
@@ -187,82 +185,127 @@ CREATE TABLE audit (
|
||||
# to cut down on space usage in the audit table. Event IDs can be predefined
|
||||
# at database create time, or defined dynamically, or both.
|
||||
CREATE TABLE auditevent (
|
||||
eventid INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
event_nsid INT NOT NULL,
|
||||
event_name VARCHAR(255) BINARY NOT NULL,
|
||||
descr TINYTEXT,
|
||||
eventid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # event ID
|
||||
event_nsid INT NOT NULL, # namespace ID of event
|
||||
event_name VARCHAR(255) BINARY NOT NULL, # event name
|
||||
descr TINYTEXT, # event description
|
||||
UNIQUE INDEX by_event (event_nsid, event_name)
|
||||
);
|
||||
|
||||
# The image store table. This is used to store relatively small images like
|
||||
# user photos and logos.
|
||||
CREATE TABLE imagestore (
|
||||
imageid INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
typecode INT NOT NULL,
|
||||
ownerid INT NOT NULL,
|
||||
ownerflag TINYINT NOT NULL DEFAULT 0,
|
||||
mimetype VARCHAR(128),
|
||||
length INT,
|
||||
data MEDIUMBLOB
|
||||
imageid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # image ID
|
||||
typecode INT NOT NULL, # image type code
|
||||
ownerid INT NOT NULL, # who owns it?
|
||||
ownerflag TINYINT NOT NULL DEFAULT 0, # owner: user or group?
|
||||
mimetype VARCHAR(128), # MIME type of image
|
||||
length INT, # length of image in bytes
|
||||
data MEDIUMBLOB # image data (max 16 Mb)
|
||||
);
|
||||
|
||||
# The image type table, used to differentiate between images stored in the table.
|
||||
CREATE TABLE imagetype (
|
||||
typecode INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
nsid INT NOT NULL,
|
||||
name VARCHAR(255) BINARY NOT NULL
|
||||
typecode INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # image type code
|
||||
nsid INT NOT NULL, # image type namespace ID
|
||||
name VARCHAR(255) BINARY NOT NULL # image type name
|
||||
);
|
||||
|
||||
#### following this line are Venice-specific tables ####
|
||||
|
||||
# The table which defines menus.
|
||||
CREATE TABLE menus (
|
||||
menuid INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
menu_nsid INT NOT NULL,
|
||||
menu_name VARCHAR(255) BINARY NOT NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
subtitle VARCHAR(255) NULL,
|
||||
menuid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # menu ID
|
||||
menu_nsid INT NOT NULL, # namespace ID of menu name
|
||||
menu_name VARCHAR(255) BINARY NOT NULL, # name of menu
|
||||
title VARCHAR(255) NOT NULL, # menu title
|
||||
subtitle VARCHAR(255) NULL, # menu subtitle
|
||||
UNIQUE INDEX by_name (menu_nsid, menu_name)
|
||||
);
|
||||
|
||||
# Definitions of variables for menus.
|
||||
CREATE TABLE menuvars (
|
||||
menuid INT NOT NULL,
|
||||
var_name VARCHAR(255) NOT NULL,
|
||||
default_val VARCHAR(255) NULL,
|
||||
menuid INT NOT NULL, # menu ID
|
||||
var_name VARCHAR(255) NOT NULL, # name of variable
|
||||
default_val VARCHAR(255) NULL, # default value of variable
|
||||
PRIMARY KEY (menuid, var_name)
|
||||
);
|
||||
|
||||
# Definitions of menu items.
|
||||
CREATE TABLE menuitems (
|
||||
menuid INT NOT NULL,
|
||||
sequence INT NOT NULL,
|
||||
itemtype VARCHAR(32) NOT NULL,
|
||||
enable TINYINT NOT NULL DEFAULT 1,
|
||||
indent INT NOT NULL DEFAULT 0,
|
||||
text VARCHAR(255) NULL,
|
||||
linktype VARCHAR(32) NULL,
|
||||
link VARCHAR(255) NULL,
|
||||
target VARCHAR(255) NULL,
|
||||
title VARCHAR(255) NULL,
|
||||
on_click VARCHAR(255) NULL,
|
||||
perm_nsid INT NULL,
|
||||
perm_name VARCHAR(255) BINARY NULL,
|
||||
ifdef_var VARCHAR(255) NULL,
|
||||
ifndef_var VARCHAR(255) NULL,
|
||||
menuid INT NOT NULL, # menu ID
|
||||
sequence INT NOT NULL, # sequence of menu item
|
||||
itemtype VARCHAR(32) NOT NULL, # menu item type
|
||||
enable TINYINT NOT NULL DEFAULT 1, # enable this menu item?
|
||||
indent INT NOT NULL DEFAULT 0, # indent level of menu item
|
||||
text VARCHAR(255) NULL, # text of menu item
|
||||
linktype VARCHAR(32) NULL, # link type to use with menu item
|
||||
link VARCHAR(255) NULL, # link for menu item
|
||||
target VARCHAR(255) NULL, # target frame for menu item
|
||||
title VARCHAR(255) NULL, # menu item title
|
||||
on_click VARCHAR(255) NULL, # menu item onClick= property
|
||||
perm_nsid INT NULL, # you must have this permission (namespace ID)
|
||||
perm_name VARCHAR(255) BINARY NULL, # you must have this permission (name)
|
||||
ifdef_var VARCHAR(255) NULL, # show item if this variable is defined
|
||||
ifndef_var VARCHAR(255) NULL, # show item if this variable is not defined
|
||||
PRIMARY KEY (menuid, sequence)
|
||||
);
|
||||
|
||||
# The table mapping category IDs to category names.
|
||||
CREATE TABLE refcategory (
|
||||
catid INT NOT NULL PRIMARY KEY,
|
||||
parent INT NOT NULL,
|
||||
symlink INT NOT NULL,
|
||||
name VARCHAR(64) NOT NULL,
|
||||
dontuse TINYINT DEFAULT 0,
|
||||
catid INT NOT NULL PRIMARY KEY, # category ID
|
||||
parent INT NOT NULL, # parent category
|
||||
symlink INT NOT NULL, # if this is a symlink, what category does it link to?
|
||||
name VARCHAR(64) NOT NULL, # category name
|
||||
dontuse TINYINT DEFAULT 0, # 1 if this is a deprecated category
|
||||
UNIQUE INDEX display (parent, name)
|
||||
);
|
||||
|
||||
# The master communities table.
|
||||
CREATE TABLE communities (
|
||||
cid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, # community ID
|
||||
member_gid INT NOT NULL, # group ID representing community members
|
||||
host_gid INT NOT NULL, # group ID representing community hosts
|
||||
host_uid INT NOT NULL, # UID of host
|
||||
aclid INT NOT NULL, # community ACL ID
|
||||
catid INT NOT NULL DEFAULT 0, # community category ID (xref to "refcategory" table)
|
||||
hide_dir TINYINT NOT NULL DEFAULT 0, # do we want to hide community from directory?
|
||||
hide_search TINYINT NOT NULL DEFAULT 0, # do we want to hide community from searches?
|
||||
name VARCHAR(128) NOT NULL, # community name
|
||||
alias VARCHAR(32) NOT NULL, # community alias
|
||||
createdate DATETIME NOT NULL, # creation date/time
|
||||
lastaccess DATETIME, # last access date/time
|
||||
lastupdate DATETIME, # last update date/time
|
||||
INDEX by_name (name),
|
||||
UNIQUE INDEX by_alias (alias),
|
||||
INDEX by_catdate (catid, createdate),
|
||||
INDEX by_create (createdate),
|
||||
INDEX by_catname (catid, name)
|
||||
);
|
||||
|
||||
# Community access table, which dictates if a community is public or private and the way people
|
||||
# have to authenticate to join it.
|
||||
CREATE TABLE commaccess (
|
||||
cid INT NOT NULL, # the community ID
|
||||
ugid INT NOT NULL, # user or group ID
|
||||
is_group TINYINT NOT NULL, # 1 if this is a group, 0 if a user
|
||||
single_use TINYINT NOT NULL DEFAULT 0, # if 1, this will be removed after a join
|
||||
auth_nsid INT NULL, # authenticator namespace ID (NULL for none)
|
||||
auth_name VARCHAR(255) BINARY NULL, # authenticator name (NULL for none)
|
||||
source_data VARCHAR(255), # authenticator source data
|
||||
auth_data VARCHAR(255), # authentication data
|
||||
PRIMARY KEY (cid, is_group, ugid)
|
||||
);
|
||||
|
||||
# The community properties table.
|
||||
CREATE TABLE commprops (
|
||||
cid INT NOT NULL, # community ID
|
||||
nsid INT NOT NULL, # namespace ID of property
|
||||
prop_name VARCHAR(255) BINARY NOT NULL, # name of property
|
||||
prop_value VARCHAR(255), # property value
|
||||
PRIMARY KEY (cid, nsid, prop_name)
|
||||
);
|
||||
|
||||
##############################################################################
|
||||
# Set table access rights
|
||||
##############################################################################
|
||||
|
||||
Reference in New Issue
Block a user