Page 1 of 1

Thoughts on structure of this database

Posted: Fri Jan 29, 2016 10:14 pm
by jrtibayan
Hi I am new to web development and is trying to make a website that keep peoples records
I want a user to be able to make his/her own form or forms
I want them to be able to make an unlimited number of forms and each form may have different number of fields
So a user lets say a teacher can have a form for recording the names and other info if his students
Then that same user can also make a form for his/her tests or favorite food of each student
I have the structure I have in mind attached with sample data on it

on the sample data there are 2 users

user jeric11 made 2 forms, one being info and the other favorite food and also filled up the both forms

I can then retrieve Records

I can display jerics info as
First Name : Jeric
Last Name: Tibayan
Address: Philippines

I can also open Jerics Favorite Food record which outputs
Vegetable : Onions
Fruit: Apple
Pizza: Pepperoni

I hope you guys can tell me if I'm on the right track.
Or suggest a better way to do it

Many thanks in advance

Re: Thoughts on structure of this database

Posted: Sat Jan 30, 2016 1:02 am
by requinix
Seems fine to me. Will every piece of data be a string? You can improve on this idea by allowing different types of data, like dates or numbers or enums (choose a value from a list).

If you're looking for more inspiration, look around for how people implement custom surveys. Same basic thing as these forms.

Re: Thoughts on structure of this database

Posted: Sat Jan 30, 2016 1:23 am
by jrtibayan
Thanks for the reply requinix. I really appreciate it. Its good to know I am on the right track. At least in making a database.

But I was kinda rethinking this project. I am very new to web development. Although I know I can loop through the data on my database to out put the forms, I have no idea if its possible to generate a dynamic php script.

Is this possible?

for example I will be using this code to validate

Code: Select all

$validation = $validate->check($_POST, array(
			'email' => array(
				'required' => true,
				'min' => 2,
				'max' => 254,
				'unique' => 'users',
				'email' => true
			),
			'username' => array(
				'required' => true,
				'min' => 2,
				'max' => 20,
				'unique' => 'users'
			),
			'password' => array(
				'required' => true,
				'min' => 6
			),
			'password_again' => array(
				'required' => true,
				'matches' => 'password'
			),
			'name' => array(
				'required' => true,
				'min' => 2,
				'max' => 50
			)
		));
Of course I will have to replace those fields and generate it out if the database

Is that doable? Should I post this on another thread?

Re: Thoughts on structure of this database

Posted: Sat Jan 30, 2016 4:28 am
by requinix
This thread is fine.

Sure, it's possible. If it seems like a lot of work, try breaking it down into small pieces and then combining the pieces to get the final result. Like write code that can validate an email, then code to call that validator based on a data type, then code to take form data and send it into the whole process.