@users #Each row represents a registered user, with privileges or without id INT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,#Internal ID email VARCHAR(255) <> UNIQUE NOT NULL,#His email for notifications xmpp TEXT <>,#His XMPP address for notifications login VARCHAR(50) <> UNIQUE,#Login name passwd VARCHAR(22) <> NOT NULL,#Password hash lastlog TEXT <>,#Where did he logged in last time? logtime TIMESTAMP,#When did he log in last time? mailgather INT UNSIGNED NOT NULL DEFAULT 240,#How long to gather mail notifications before sending? xmppgather INT UNSIGNED NOT NULL DEFAULT 15,#How long to gather xmpp notifications before sending? nextmail TIMESTAMP,#When do we send pending email notifications next time? nextxmpp TIMESTAMP#When do we send pending xmpp notifications? @locations #The locations are saved in a tree. ID of the location is created by #appending the local IDs of the nodes on the path together (children of #the root first), separated by '/'. Each node must know, how long are #the local IDs of its children. # #(Note that the local IDs can contain '/', since it can be recognized #by its length.) # #The first part is 2-letter specifier of information type. The first #version has these: #PC: PCI ID #PD: PCI Device Class # id VARCHAR(50) <> NOT NULL UNIQUE PRIMARY KEY,#The name of the location, must be just node, no / at the end parent VARCHAR(50) <>,#To allow selecting of all node's children mainhistory INT UNSIGNED,#Reference for the main history name TINYTEXT <>,#Should match the one of main history, if any (if no main history, name can be set too) note TEXT <>,#Should match the one of main history (if no main history, can be set too) CONSTRAINT parent_ref FOREIGN KEY (parent) REFERENCES locations(id) ON DELETE CASCADE @rights #Which privileges the users have? #It contains only the users with some extra privileges, not the normal ones userId INT UNSIGNED NOT NULL,#Who has the privilege rightId INT UNSIGNED NOT NULL,#What privilege CONSTRAINT right_user FOREIGN KEY (userId) REFERENCES users(id) ON DELETE CASCADE, PRIMARY KEY (userId, rightId) @history #Contains the discussion and history of items id INT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY, owner INT UNSIGNED,#Who posted it? location VARCHAR(50) <> NOT NULL,#Where it belongs discussion TEXT <>, time TIMESTAMP NOT NULL DEFAULT NOW(),#When this was added nodename TINYTEXT <>,#Modification of the location name nodenote TEXT <>,#Modification of the location note seen BOOLEAN NOT NULL DEFAULT '0', #Did some admin see this, or is it still unseen? CONSTRAINT history_location FOREIGN KEY (location) REFERENCES locations(id) ON DELETE CASCADE, CONSTRAINT history_owner FOREIGN KEY (owner) REFERENCES users(id) ON DELETE SET NULL @notifications #Contains hooks for notifications user INT UNSIGNED NOT NULL,#Who wants it location VARCHAR(50) <> NOT NULL,#Where recursive BOOLEAN NOT NULL DEFAULT '0', type SMALLINT NOT NULL,#When to send #0: History -- When a new discussion is posted #1: Description -- Name or note changed #2: MainHistory -- The main history changed #All contains the less common events notification SMALLINT NOT NULL, #0: mail only #1: xmpp only #2: both CONSTRAINT notification_location FOREIGN KEY (location) REFERENCES locations(id) ON DELETE CASCADE, CONSTRAINT notification_user FOREIGN KEY (user) REFERENCES users(id) ON DELETE CASCADE, PRIMARY KEY (user, location) @pending #Contains the pending notifications user INT UNSIGNED NOT NULL, history INT UNSIGNED NOT NULL, notification SMALLINT NOT NULL, #0: mail #1: xmpp #If a notification generates both, it splits to 2 of them reason SMALLINT NOT NULL, #0: New item #1: New history #2: Changed main article CONSTRAINT pending_history FOREIGN KEY (history) REFERENCES history(id) ON DELETE CASCADE, CONSTRAINT pending_user FOREIGN KEY (user) REFERENCES users(id) ON DELETE CASCADE