Answer the question
In order to leave comments, you need to log in
How to create a model, controller and views on a table in which all fields are keys?
Greetings.
the database has an automatically created table "webpages_UsersInRoles", where pairs of records are stored - a user ID and a role ID.
CREATE TABLE [dbo].[webpages_UsersInRoles] (
[UserId] INT NOT NULL,
[RoleId] INT NOT NULL,
PRIMARY KEY CLUSTERED ([UserId] ASC, [RoleId] ASC),
CONSTRAINT [fk_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[UserProfile] ([UserId]),
CONSTRAINT [fk_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [dbo].[webpages_Roles] ([RoleId])
);
Answer the question
In order to leave comments, you need to log in
Do you want that in the view you would not have IDs, but, for example, the name of the user and role? If yes, then simply pass the appropriate fields by ID.
How do you like this:
1. Create a new entity with your unique ID - pages2userRoles
2. Add a Foreign key there for those things that you want to link - userProfile and webPage, respectively
3. Create a composite index on the label of this entity (for quick search)
4. Pass all calls in the code through this new entity.
those. the idea is that the entity has a PRIMARY KEY column in a separate column (different ORMs often break without such a column).
You can create a composite search index yourself, by hand.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question