Database Model For Status Property
When I create a model for a ticket I want to save in a database, and this ticket has a property "status", how should setting this value be reflected properly in the database?
I would think of creating two tables, with Table 1: Tickets and Table 2: Ticket_Status. As an example it could look like:
id, status, message
I think it would be a ManyToMany relationship and I therefore would need a pivot table? So would this be the right approach, instead of saving the status directly in the ticket entry, I would save the different types in this separate table and use the ManyToMany relationship via pivottable?
If you want a history of the status you have to use a ManyToMany relationship and a pivot table.
If only want to show the actual status make a unique table
Tickets: id, status, message
Its a good practice if you at least in database have and history of the status changes. (First Option)
- → I can't do a foreign key, constraint error
- → How to implement DbDongle::convertTimestamps as workaround of invalid timestamps with MySql strict
- → MySQL error "Foreign key constraint is incorrectly formed"
- → Eloquent Multitable query
- → "Laravel 5.1" add user and project with userId
- → Database backup with custom code in laravel 5 and get the data upto 10 rows from per table in database
- → Laravel 5.1 QueryException when trying to delete a project
- → Using Array in '->where()' for Laravel Query Building
- → Chaining "Count of Columns" of a Method to Single Query Builder
- → Laravel Eloquent Joining Strange query
- → convert time using mysql laravel 5
- → How to update a column after an expiration date in MySQL?
- → Foreign key constraint fails on existing key