Guys I am trying to make a simple ticket generation system for my company as a favor. For now, I have a table called tblTicket
and another table called tblEng
Standard practice would be this, as an example...
You have a "tblEngineer" table...
tblEngineer
-----------
(PK) EngineerId
EngineerName
And a "tblTicket" table...
tblTicket
---------
(PK) TicketId
TicketDetails
You now add a link table called "tblEngineerTickets" (or similar) which references the Ids of both the Engineer and their tickets...
tblEngineerTickets
------------------
(PK) EngineerTicketId
(FK) EngineerId
(FK) TicketId
So that way, you keep all the Ticket Details and the Engineer details separately, and link them using ONLY the Ids... the link table would look something like this...
EngineerId | TicketId
------------+----------
1 | 1
1 | 2
1 | 3
2 | 1
2 | 2
2 | 3
This way, you can have multiple engineers assigned to one ticket, and/or multiple tickets assigned to an engineer.
This is best practice and it gives you the most opportunity for expansion. If you were to just add fields to your existing Engineer tables saying "Ticket1", "Ticket2", "Ticket3" etc... you would be effectively be placing a limit on the code, and potentially you'd have to keep going in to the code to add columns.
I would suggest making 1-to-Many relationships instead of making many-to-many relationships. You can accomplish this by having a table that maps between your tblTicket
and tblEngineer
. For Example:
tblEngineer
-----------
(PK) iEngineerID
tblTicket
---------
(PK) iTicketID
tblTicketEngineerMap
--------------------
(PK) iMapID
(FK) iEngineerID
(FK) iTicketID
By doing it this way, an Engineer and a Ticker can be in many maps, making two 1-to-Many relationships, and allowing the functionality you seek.
Check out this thread as to why you should try to avoid many-to-many table designs.
Use a column to store different logic values: check this link http://sqlpro.developpez.com/cours/stockageopt/
This means that 3 tables are necessary for data manipulation, including a significant cost to the relational query engine.
Are there way to simplify this by integrating all these data within the Member table?
Assign a code to each state:
tblTicket ( id_Ticket , Engineers )
Engineers( id_eng , other columns)
in tblTicket Engineers you can set multiple value like id_1 - id_2 - id_3 ( 1-2-3) 3 engineers
tblticket ( id_ticket , other columns ) ( primary key : id_Ticket )
engineers ( id_Eng , other columns) ( primary key : id_Eng )
TicketEng ( id_Ticket , id_Eng ) ( primary key : (id_Ticket , id_Eng) )