Relational Ado Without Primary Foreign Key Relation in yii - activerecord

I have 2 tables. one is groups and other is frames.
groups has id, name, owner as columns.
grouppage has id,name and user_id.
users can have group pages. users can edit page if they are owner of the group .Means user_id = owner. Otherwise users can not edit the group page.
Hence i have a public property called can_edit.this is true if user_id = owner.
now i want to connect these 2 table using relational ADO. But how do i do it? because i have to connect the user_id in grouppage table to owner in groups. Neither owner nor group_id are primary keys?
Any solution /ideas
Thanks to all
Smith

Related

Is it possible to use Oracle Label Security in Entity Framework Data Context?

I have a table configured with an OLS policy (levels, compartments, groups) - a user with a specific OLS user label can only access some rows in the table according to their OLS data label. Right now, I'm using strings to connect to the Oracle Database then make a query from that table (like "select * from mytable"). May I ask is it possible to use Entity Context for that? Like one data context but multiple user Oracle account (schemas) with different user labels query from that single Entity context so that I don't have to use strings?
Label security (OLS) affects the rows shown to a user - not colums etc.
i.e. the data model is for any user allowed to select the tables the same - so if you got User1 granted to select table T1 but OLS restricted access for User1 to data connected to asian location, User1 will see only asian data but not rows for european locations - If User2 is a "superuser" - i.e. allowed to fetch rows from any location, User2 will see any rows.
The simpliest way to prove this is to do
desc T1
Both users will see same table description - and thats what EF / LINQ relates on. So - as User with OLS and granted select table you got 0, subset or all rows - but Everytime table description

Laravel 5 from Pivot-Table to Many

how can I access in Laravel 5 from the pivot table the users if i have a relation like this:
users (id)
roles (id)
user_role (user_id, role_id)
I select the user_id's and now i want the users.
Thank you
You need to set up your relations in User model and Role model. Please refer to the laravel documantation.
https://laravel.com/docs/5.1/eloquent-relationships#many-to-many

How to create new schema and list all schema name in oracle

I want to create one new schema in oracle and I used sample code, which is available here
CREATE SCHEMA AUTHORIZATION oe
CREATE TABLE new_product
(color VARCHAR2(10) PRIMARY KEY, quantity NUMBER)
CREATE VIEW new_product_view
AS SELECT color, quantity FROM new_product WHERE color = 'RED'
GRANT select ON new_product_view TO scott
/
But, getting error
ERROR at line 1:
ORA-02421: missing or invalid schema authorization identifier
Also, Please help me how to list name of all available schema. I am using
select username from dba_users;
to list schema, but i think, its not a right approach, because, user and schema has many-to-many relation,which means I can't get all schema name here.
Please help me !!
From oracle documentation:
This statement does not actually create a schema. Oracle Database
automatically creates a schema when you create a user
So you first need to create a User with the schema name
As for your query it's fine, since username list is equal to schema names unavailable
UPDATE: I can't really test it now, but should be something like this:
CREATE USER oe IDENTIFIED BY oePSWRD;
CREATE SCHEMA AUTHORIZATION oe
CREATE TABLE new_product
(color VARCHAR2(10) PRIMARY KEY, quantity NUMBER)
CREATE VIEW new_product_view
AS SELECT color, quantity FROM new_product WHERE color = 'RED'
GRANT select ON new_product_view TO scott;
From the docs: http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_6014.htm
The schema name must be the same as your Oracle Database username.
Do you want to find all users, or all users for which a table (for example) exists? If the latter then ...
select distinct
owner
from
dba_tables
where
owner not in ('SYS','SYSTEM')
Add in other usernames that you're not interested in listing as required.

Wavemaker Service Variable HQL update foreign key column

I have two tables employee, department with a one to many relationship such that a column name 'depRefID' in employee references the primary key of the 'department' table.
I have a dojogrid that fetched data from employee table via a Service variable and a select menu that lists the department names.
I've setup an onchange function on the select menu that, would ideally loop each selected row in the employee table and change its foreign key to the one selected via the select widget.
I'm trying to use a separate service variable to update "employee" table using and update query.
How can I reference or access the foreign key 'depRefID' in HQl as directly referencing it throws an exception.

Codeigniter: how should I restructure db schema?

I don't even know if that's the right term.
May it be known that I'm a major novice!
I have three tables: users, profiles, and survey. Each one has user_id as it's first field, (auto-increment for users), and they're all tied by a foreign key constraint, CASCADE on DELETE.
Currently, for each user, let's say user_id 1, they have a corresponding db entry in the other tables. For profiles it lists all their information, and the survey table holds all their survey information.
Now I must change things...darn scope creep. Users need the ability to have multiple survey results. I imagine that this would be similar to a comment table for a blog...
My entire app runs around the idea that a single user is linked to a constraining profile and survey.
How should I structure my db?
How should I design my app's db so that a user can have multiple tests/profiles for the test?
Please assist! Any advice, information and personal-knowledge is appreciated!
Right now the only way I know how to accompany my client is to create a pseudo-user for each test (so unnecessary) and list them in a view table (called "your tests")-- these are obtained from the db by saying: where user_id=manager_id
Right now, survey has a foreign key to user, identifying the user who took the survey. This is good, and does not change.
But add an autoincrement primary key to survey (and to profile, too). Now a user can have multiple surveys. Each individual survey has its key, and its taker is identified by the user foreign key.
To find all surveys for all users:
select a.*, b,*
from user a
join survey b on (b.user_id = a.user_id);
To find all surveys for one user:
select a.*, b,*
from user a
join survey b on (b.user_id = a.user_id)
where a.user_id = some_user_id;
To just get the survey data, just select b.* only. For example:
select b.*
from survey b on
where a.user_id = ( select user_id from user a where a.name = 'Bob' );
Again, all you need to do is add a primary key (which should be an autoincrement) to survey.

Resources