Tables Relations Problem with primary key and Foreign keys??

  • I am not Much Known about Database So please solve my problem and suggest me some example for security module How to make relation in this process??

    Security Module:

    Employee: (employeeId , branchId ,employeeName,departmentId,        userId            ,address1,address2,city,state,zip,country,mobile,phone,hireDate,active)

    User: (userId,branchId,username,userPassword,description,alertLoginStatus,groupId)

    Groups: (groupId,groupDescription,groupName)

    GroupRightsgroupId,admObject,croObject,dealerObject,rights)

    AdmObject: (admObject,objectName)

    CroObject: (croObject,objectName)

    DealerObject: (dealerObject,dealerId,ObjectName,commissionCode)

     

    Explanation:

    This is our security module First of all User table have userId,BranchId as a primary key .user table primary key relate to the employee table ,Groups as a foreign keys. In the Groups table groupId is a primary key and relate to the Users,GroupsRights table as a foreign key. AdmObject, CroObject, DealerObject tables have primary keys and relate to the Groups Rights as a Foreign Key.

    When we start /run as a visual studio .Net this application they create a problem and send the error that FK_ User and Groups  ,FK_Employee , Users that’s relation are not correct So what we do to solve this problem .??

     

    ERROR OCCUR IN VISUAL STUDIO .NET 20003

    these error occur when we run the application please tell me how to solve and see these my relation which are made in sql server .

    Server: Msg 547, Level 16, State 1, Procedure SP_InsertNewUser, Line 27

    INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_Users_Branches'. The conflict occurred in database 'Security33', table 'Branches', column 'branchId'.

    The statement has been terminated.

    Server: Msg 547, Level 16, State 1, Procedure SP_InsertNewUser, Line 30

    INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_Employee_Users'. The conflict occurred in database 'Security33', table 'Users', column 'userId'.

    The statement has been terminated.

    The 'SP_InsertNewUser' procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead.

    Stored Procedure: Security33.dbo.SP_InsertNewUser

     Return Code = 0

  • OK, so you're trying to run a stored procedure SP_InsertNewUser, right?  It sounds as if you've given your new user a branchId that does not exist in the Branches table.  Then you are trying to create a new Employee based on that User, which also fails because there is no user with that userId.

    John

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply