Welcome Guest, Not a member yet? Register   Sign In
HELP with automating database table with a backend
#1

[eluser]dippy[/eluser]
The idea here is to have a backend and once logged in there will be an option to add a new service category. When a new service category is added to the services table in the database the application will create a new table in the db for that service (for vendors/clients that will be in assigned to that service). Then ask the user/admin what fields are going to be used for this service, create the fields in the db and from there it will generate a simple form with labels and input boxes so when the user/admin adds a new vendor and he wants to assign that vendor to a service that form will show up with the correct fields from the db.

is this a possible?

i would like to have it so the user has control of what fields and info they collect from the client/vendor for that particular service.

i was going to hard code in what fields they will need for each service and create the db tables according to the form fields. but it would make life a lot easier if the user had control. it would pretty much be a scaffolding section for just adding a service.
#2

[eluser]slowgary[/eluser]
I'm confused by your description, but probably because I didn't feel like drawing a picture of it with a pen and paper Smile

I think maybe there's a better way to do what you're attempting. I'm not entirely sure what that is (that you're attempting), but I'm just guessing it's a bad idea to allow users to create database tables. What happens when you have 1000 users? How does your app determine which table to search from?

Again, I haven't taken the time to understand your problem, but I bet there's a WAY better method of implementing your needs. Try doing something more along these lines:
Code:
services table
======================
service_id
service_field1
service_field2

attributes table
======================
attr_id
attr_name

service_attributes table
======================
service_id
attr_id

service_values table
======================
service_id
attr_id
value

This way your users can create new services, and different services can reuse the same attributes. So you'd add new services to the services table, new 'fields' to the attributes table, then you'd store an entry in service_attributes for each field that belongs to a service. Then when it comes time to submitting the form, you'd store the actual values in the service_values.

Does that sound similar to what you're trying to do?

Hope this helps.
#3

[eluser]dippy[/eluser]
yes thank you very much.


just to clarify there is going to be one user adding services. for example. the admin wants a service on the site to add tow truck vendors. they will goto the services tab add a new service called "towing" and then the application will ask if they want to add custom fields for this service when taking vendor information. The admin wants the following custom fields: Tow truck drivers, insurance info, plate #. So there will be an input box with an add button to add additional fields.

then when the admin adds a new vendor and selects to assign that vendor under the towing service the application will generate a form for the admin to enter the Tow truck drivers, insurance info and plate #.

See where I'm going with this?
#4

[eluser]slowgary[/eluser]
I see. So while the above schema may need a bit of tweaking to fit your circumstance, I still think it's a much better way than allowing the user to create tables, which is not considered a good practice (by me).
#5

[eluser]dippy[/eluser]
that's fine, i understand. i appreciate the help.

thanks again.




Theme © iAndrew 2016 - Forum software by © MyBB