Modeling / Design Class Request

How would I simulate such a situation? How to create a database? What classes should I have?

Statement of problems: Each employee belongs to at least one project, each project has many tasks, each task is assigned to at least one employee.

I should be able to deflate

  • project staff.
  • project related tasks
  • tasks that this employee is working on.

etc.

Are circular / circular relationships a bad design, can it be eliminated?

How should entities represented in the database? How should objects be represented using classes?

Thanks in advance,

+3
4

, , , . .

tblProject
    ProjectID
    ProjectDescription etc.

tblTask
    TaskID
    TaskDescription etc.

tblEmployee
    EmployeeID
    Name etc.

tblProjectTasks
    ProjectTasksID
    ProjectID
    TaskID

tblTaskAssignments
    TaskAssignmentsID
    TaskID
    EmployeeID

- , , . . , , , . , , . , , .., / .

, , , , , . IMHO, , , . .

. . OO , . , .

+1

, , , . , ... , :

There are many Projects
Projects have Employees
Projects have Tasks
Employees are assigned some Tasks

... (, , , ). , , "" , .

, , , , () ? , , , , ... , , , . , "", . Project Employee, Employee Project ( ).

, . . , , , , , - ... . , ..

+1

. , . / ? ? ...

:

Projects
    ProjectID
    ProjectName...
    EmployeeID

Tasks
    TaskID
    ProjectID
    TaskName...
    EmployeeID

Employees
    EmployeeID
    EmployeeName...
0

- :

    Create Table Projects
(
    ProjectID int Identity(1,1),
    ProjectName varchar(50) Primary Key NonClustered,
    OtherStuff varchar(255)
)
CREATE CLUSTERED INDEX IX_PROJECTS_ID ON dbo.Projects(ProjectID)

Create Table Employees
(
    EmployeeID int Identity(1,1),
    EmployeeName varchar(50) Primary Key NonClustered,
)
CREATE CLUSTERED INDEX IX_EMPLOYEES_ID ON dbo.Employees(EmployeeID)

Create Table ProjectEmployees
(
    ProjectID int,
    EmployeeID int,
    Constraint pk_ProjectEmpoyees Primary Key (ProjectID, EmployeeID)
)

Create Table Tasks
(
    TaskID int Identity(1,1),
    TaskName varchar(50) Primary Key NonClustered,
    AssignedEmployeeID int, --NOTE: assumes only 1 employee per task
    OtherStuff varchar(255)
)
CREATE CLUSTERED INDEX IX_TASKS_ID ON dbo.Tasks(TaskID)

Create Table TaskPrecedents
(
    TaskID int,
    PrecedentTaskID int,
    PrecedentType Char(2)   --Codes, you'll have to work these out
    Constraint pk_TaskPrecedents Primary Key (TaskID, PrecedentTaskID)
)
0

Source: https://habr.com/ru/post/1709619/


All Articles