 
 
 
-/* 	SELECTING DOCUMENT FOR EACH GROUP
-	
+/**********************************************************************************
+ **********************************************************************************
+ **********************************************************************************/
+
+
+
+/* 	REGISTERING SUPERADMIN
+	Password has to be hashed, SALT to be determined by hashing creation_date, no avatar img yet
+*/
+
+INSERT INTO `ipp_users` (`first_name`, `last_name`, `password`, `creation_date`, `email`, `avatar`, `superadmin`)
+VALUES					('super', 'admin', 'adminpwd', 'admin_creation_date', 'admin.internet@programming.fi', 'to_be_defined', TRUE);
+
+
+
+/* 	REGISTERING STANDARD USERS
+	Password has to be hashed !!!
+	First run loggin SQL to check that given email/password are unique in the table !
+*/
+
+INSERT INTO `ipp_users` (`first_name`, `last_name`, `password`, `creation_date`, `email`, `avatar`)
+VALUES					(/* user_input */, /* user_input */, /* user_input */, /* generated_creation_date */, /* user_input */, /* manage file upload */);
+
+
+
+/* 	LOGGING USERS IN
+	total should be = 1 that means, only one match, then loggin is succesful
+	if total = 0, ask for registration
+	if total > 1, we have a structural problem, because two users in the table have been registered with identical emails and passwords...
+*/
+
+SELECT count(`id`) as total 
+FROM `ipp_users` 
+WHERE `email`=/* user_input */
+AND `password`=/* user_input */
+
+
+
+
+/* 	SELECTING GROUPS FOR EACH USER	
+*/
+
+SELECT `ipp_group`.`name`
+FROM `ipp_group`
+INNER JOIN `ipp_group_join`
+ON `ipp_group_join`.`group_id` = `ipp_group`.`id`
+INNER JOIN `ipp_users`
+ON `ipp_group_join`.`user_id` = `ipp_users`.`id`
+WHERE `ipp_group_join`.`user_id` = /* Current user id */
+
+
+
+
+/* 	SELECTING DOCUMENT FOR EACH GROUP 
 */
 
 SELECT `ipp_document`.`name`

  `superadmin` BOOLEAN default FALSE,
  PRIMARY KEY  (`id`)
);

/* 	REGISTERING SUPERADMIN
	Password has to be hashed, SALT to be determined by hashing creation_date, no avatar img yet
*/

INSERT INTO `ipp_users` (`first_name`, `last_name`, `password`, `creation_date`, `email`, `avatar`, `superadmin`)
VALUES					('super', 'admin', 'adminpwd', 'admin_creation_date', 'admin.internet@programming.fi', 'to_be_defined', TRUE);

/* 	REGISTERING STANDARD USERS
	Password has to be hashed !!!
	First run loggin SQL to check that given email/password are unique in the table !
*/

INSERT INTO `ipp_users` (`first_name`, `last_name`, `password`, `creation_date`, `email`, `avatar`)
VALUES					(/* user_input */, /* user_input */, /* user_input */, /* generated_creation_date */, /* user_input */, /* manage file upload */);

/* 	LOGGING USERS IN
	total should be = 1 that means, only one match, then loggin is succesful
	if total = 0, ask for registration
	if total > 1, we have a structural problem, because two users in the table have been registered with identical emails and passwords...
*/

SELECT count(`id`) as total 
FROM `ipp_users` 
WHERE `email`=/* user_input */
AND `password`=/* user_input */

/* 	CREATING IPP_GROUP TABLE
*/

  PRIMARY KEY  (`id`)
);

/* 	CREATING IPP_DOCUMENTS TABLE
*/

