Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8536169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:36:02+00:00 2026-06-11T10:36:02+00:00

I’m in training period and my trainer gave me some database exercises. I have

  • 0

I’m in training period and my trainer gave me some database exercises.

I have to make Project, Employee, Roles and Employee_Projects_Role tables. Last table has the details of the employees working on a project with a specified role.

The conditions he gave to me are:
1. One employee can work in multiple projects.
2. One employee can not have different roles in same projects.

I made those tables and inserted the data. In roles, I had roles Leader, Manager, Developer. I made those tables and entered the data.

He checked my tables and said that a project have more than 1 leader and 1 manager so I restricted the columns like there wont be same roles in one project but now I can not enter 2 developer to that mapping table in one project.

But a project can obviously has 2 developers. So, If you understand the whole scenario then I want to ask that is that possible to restrict a particular column that it would be having only one leader and manager in one project?

I am not really into database but before assigning me a project work he wants to just brush up my basics. So, I am really confused in that.

Schema for those tables is as following:

  1. Project with following fields :
    project_pid – primary key,
    project_name

  2. Employee with following fields:
    employee_pid – primary key,
    employee_name,
    gender – M/F,
    salary,
    date_of_joining,
    is_active – Y/N

  3. Roles with following fields:
    role_pid – primary key,
    role_name – (team member or leader)

  4. Employee_Project_Role with following fields:
    project_xid – foreign key (references table Projects),
    employee_xid – foreign key (references table Employee),
    role_xid – foreign key (references table Roles)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:36:03+00:00Added an answer on June 11, 2026 at 10:36 am

    To implement such logic, you need to use procedural language. The easiest way in my opinion is defining a trigger:

    CREATE TRIGGER role_restrict
    ON employee_project_role
    FOR INSERT, UPDATE
    AS
      BEGIN
          DECLARE @role VARCHAR(100)
          DECLARE @ldr_xid VARCHAR(100)
    
          SELECT @role_xid = (SELECT role_xid
                              FROM   inserted)
    
          SELECT @ldr_xid = (SELECT role_xid
                             FROM   roles
                             WHERE  role_name = "leader")
    
          IF @role = @ldr_xid
             AND (SELECT Count(*) AS cnt
                  FROM   employee_project_role
                  WHERE  project_xid = (SELECT project_xid
                                        FROM   inserted)
                         AND role_xid = @ldr_xid) > 1
            /* Cancel the insert, there is already a leader in a project.*/
            BEGIN
                ROLLBACK TRANSACTION
            END
      /* Otherwise we insert the record */
      END  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a reasonable size flat file database of text documents mostly saved in
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.