How to list all the roles existing in informix database? - informix

I know in sysusers table, we can see roles associated with each user in defrole column.
Now I have been searching in below tables:
B_APP_ROLES
ROLES
But I can't find roles defined in defrole column in above tables.
Also can we see which tables have granted what roles?

dbschema -r all -d database_name should list all the roles created and grants to those roles for that particular database.
This information I believe would be coming from the sysroleauth table.
Then if you want to see what table level permissions a particular role has, the role name would be the grantee column in systabauth.
So the query would be like
select * from systabauth where grantee = "rolename";

Related

Strange Assignee names coming from Assignee column in jiraissue table

I am using Jira backend database to pull some columns for reporting. Assignee column in jiraissue table stores the Webkey ID/usernames of all the employees. I join this with cwd_user to get the full name of the assignee. But I also see some weird values like the ones below. I don't have a clue about how to get the display names of these users. They are not Webkey ID/usernames.
Any thoughts on what I might be missing?
The app_user table has the current userid in the lower_user_name column
If you're running a recent version of Jira, there was a GDPR-related change that causes all newly-created users to have a key starting with JIRAUSER instead of their username. Users can also be anonymized through this feature.
You can get a mapping of JIRAUSER keys to usernames through the JIRA API's Get User endpoint -- not sure where to look in the database for this mapping yet.

Accessing data from two or more schemas in a multi tenant application

We are using apartment gem for multi-tenant application. For each account, there will be a separate schema is maintained. based on the subdomain of the account, we list the data in each account.
In our new requirement, there is something like a super account where all the account data can be viewed. For example, if account 1 and account 2 is selected in the user list page, users of account 1 and 2 should be combined and viewed along with search provision. Is there any way to combine more than one schema data in the apartment? or any other alternates
The simplest approach I can think of is to perform union queries across the relevant schemas. So if you have schemas account_1 and account_2, you'd do something like SELECT * FROM account_1.users UNION SELECT * FROM account_2.users.
You can, of course, make this dynamic – so if you send the affected accounts as part of the params hash, you'd potentially have something like this:
accounts = Account.find(params[:account_ids])
# assuming the schema name is stored in the accounts.tenant_name column:
sql = accounts.map { |account| "SELECT * FROM #{account.tenant_name}.users" }.join(" UNION ")
users = User.find_by_sql(sql)

How to design database tables for different types of Users?

I'm on a project with Rails, Postgresql and Active Record, where I have Users, that can be either Influencers, or Creators.
The Users have common columns such as email, password, first_name and last_name, but :
influencers will have followers, eg_rate, account columns
creators will have SIRET_number and specialty columns
How can I design my database so Influencers and Creators are kind of "child" of the Users table ? I mean, is it possible to have a db where I can access a User' followers or a User's specialty with one query, or I'll always have to do multiple queries to achieve this ? I've tried to create three tables for each, with a foreign key user_id in Influencers table and Creators table. I also tried to add a user_type column to my User table where I pass the values of either "influencer" or "creator", but I'm kind of lost on how to link every tables...
Thank you everyone.
Your approach is right.
You can create a table users with the common columns and add a foreign key to influencers and creators tables.
Then when you need to retrieve the data, you can use ActiveRecord relations to easily fetch data and use ActiveRecord's includes method for relations.
For example:
class Creator < ActiveRecord::Base
# The relation must be set
has_one :user
end
# To fetch data anywhere else:
Creator.find_by(SIRET_number: 1234).includes(:user)
If you need to retrieve a creator or influencer by an attribute from related users table, you can use joins:
Creator.joins(:users).where(users: {email: "foo#bar.com"})
Make sure you have the relations set in both User and Creator models.
Check out this topic for more info.
By using includes or joins instead of using creator.user you'll avoiding the unnecessary additional query. The downside is the syntax is now longer, you can maybe create your own getters to easily retrieve data instead of writing "includes" everytime.
Also assuming you're not aware of this method, I suggest you to read about the common N+1 problem with Rails & ActiveRecord. The same methods can solve a lot of problems for you.

Is there any way to join the Identity user table with any other table (Product) of our own in MVC 5

Is there any way to join the Identity user table with any other table of our own in MVC 5. Because fetching the data is really difficult. If we want to retrieve user product on the bases of some roles and then their products. So its a join of three tables but join of Products table with other two tables i don't know how to use this. Because User and Roles tables are identity table and belongs to IdentityDbContext.

"permission" fields on a join table (relationship model) in rails

I have a relationships model that holds 2 user_ids, a follower_id and a followed_id
When a user "follows" another user a relationship record is added which includes these two id's. I would like the followed user to have some say as to what the following user can see, so I am thinking of adding adding field(s) to the record, such as "followed_user_allows_follower_to_see_email_address" (it would be a less verbose)
This seems like the correct place to add these attributes, are there any reasons I should store these some place else?
Is there any reason I should not just store a list of permissions, rather than an attribute for each permission? For example followed_user_allows_follower_to "see_email_address,see_some_other_detail,yet_another_detail" vs a separate field for each permission.

Resources