@ViktorAlm I’m struggling to understand the use case for your application, but my gut feeling is that users should not be creating tables in your database.
User-created tables, database design
Hey!
I made a php application a while back to create, update and search data in user-defined tables. The different columns can be of various types like multiple select, textarea, text and so on.
We've been using it for member lists with volunteers for my university's different societies and for some archives inventory, but my goal is to build a general purpose database storage tool for collaboration.
The way the existing application works is that when a user creates a new table the application creates a new table in MySQL and saves the data about the different column types and other things required to display the table in another table.
Right now it looks something like this
ex. Volunteers registration
Code created table: 1
| Id | 1 | 2 | 3
|----- | -------- | ----------- | -------------
| 0 | XX XX | XX@XX.com | Cooking, Recruiting, IT
| 1 | XY XY | XY@XX.com | Athletics, Bartender
TableOptions
| Id | TableId | ColumnId | Name | Type | Options | Required
| -- |------- | ------ | ---- | -------------- | -------- |-------
| 0 | 1 | 1 | Name | Text | null | 1
| 1 | 1 | 2 | Email | Text | null | 1
| 2 | 1 | 3 | Volunteer | Multiple select | Cooking, Recruiting, IT, Athletics, Bartender | 1
With these tables a form for adding data and a jQuery Datatable for displaying data is created with my not-so-great php code. This has been bugging me for the last few years and I want to build a new version with Laravel. What the user sees in a jQuery dataTable
| Name | Email | Volunteer
| -------- | -------------- | -------------------------------------
| XX XX | XX@XX.com | Cooking, Recruiting, IT
| XY XY | XY@XX.com | Athletics, Bartender
What is the best solution for an application like this where users can create and update tables in Laravel?
I've asked my SQL teacher and he couldn't give a definitive answer. His solution was to have one table with columns a-z and use another table like my TableOptions to build the different tables. I dont really like any of the solutions and there must be a better way of doing this? and how would I go about doing it in Eloquent? Is it possible? Do I have to go NoSQL?
It would be great if someone more experienced could point me in the right direction with an example or a book to read or a phrase to google. Anything is appreciated.
Please or to participate in this conversation.