背景:
Agame
は aに属しround
、
Aは a にround
属しseason
、
Aは a にseason
属し、competition
Acompetition
は所有されていません。
8つのテーブルがあります
名前 => 列
`games` => `id`, `round_id`,
`rounds` => `id`, `season_id`,
`seasons` => `id`, `competition_id`,
`competitions` => `id`,
----
`user_game` => `user_id`, `game_id`,
`user_round` => `user_id`, `round_id`,
`user_season` => `user_id`, `season_id`,
`user_competition` => `user_id`, `competition_id`
したがって、最初の 4 つのテーブルはさまざまなパーツをリンクし
、次の 4 つのテーブルはユーザーをそれぞれのパーツにリンクします。
いくつかのダミー データです。読みやすいように 2 番目の ID が変更されたときにテーブルを分割したことに注意してください。
最初の 4 つのテーブル
/--GAMES--------------\ /--ROUNDS-------------\
| id | round_id | | id | season_id |
| 1 | 1 | | 1 | 1 |
| 2 | 1 | | 2 | 1 |
|----|----------------| | 3 | 1 |
| 3 | 2 | |----|----------------|
| 4 | 2 | | 4 | 2 |
|----|----------------| | 5 | 2 |
| 5 | 3 | | 6 | 2 |
| 6 | 3 | |----|----------------|
|----|----------------| | 7 | 3 |
| 7 | 4 | | 8 | 3 |
| 8 | 4 | | 9 | 3 |
|----|----------------| |----|----------------|
| 9 | 5 | | 10 | 4 |
| 10 | 5 | \---------------------/
|----|----------------|
| 11 | 6 | /--SEASONS------------\
| 12 | 6 | | id | competition_id |
|----|----------------| | 1 | 1 |
| 13 | 7 | | 2 | 1 |
| 14 | 7 | |----|----------------|
|----|----------------| | 3 | 2 |
| 15 | 8 | | 4 | 2 |
| 16 | 8 | \---------------------/
|----|----------------|
| 17 | 9 | /--COMPETITIONS-------\
| 18 | 9 | | id |
|----|----------------| | 1 |
| 19 | 10 | | 2 |
| 20 | 10 | \---------------------/
\---------------------/
次の 4 つの表は、以下のリストで最もよく説明されています
ユーザー:
- ユーザー 1
- ゲーム 1 のみにリンク:
user_game (user_id:1, game_id:1)
direct
ゲーム 1にアクセスできますparent
ラウンド1にアクセスできますparent
シーズン 1にアクセスできますparent
コンペティション 1にアクセスできます
- ゲーム 1 のみにリンク:
- ユーザー 2
- ラウンド 1 のみにリンク:
user_round (user_id:2, round_id:1)
child
ゲーム 1、2にアクセスできますdirect
ラウンド1にアクセスできますparent
シーズン 1にアクセスできますparent
コンペティション 1にアクセスできます
- ラウンド 1 のみにリンク:
- ユーザー 3
- ラウンド 1 にリンク:
user_round (user_id:3, round_id:1)
- ユーザー 2のすべてのアクセス権を持つ
- ゲーム 2 にリンク:
`user_game (user_id:3, game_id:2)。 direct
ゲーム 2にアクセスできます- ゲーム13にもリンクされています:
user_game (user_id:3, game_id:13)
direct
ゲーム 13にアクセスできますparent
ラウンド7でアクセス可能parent
シーズン3にアクセスできますparent
コンペティション 2にアクセスできます
- ラウンド 1 にリンク:
したがって、上記の 3 人のユーザーのアクセス権を取得するときは、これら 3 つの配列で終了したいと考えています。次の点に注意してください
parent_access
。direct : ユーザーは、親オブジェクト (オブジェクトに関係なく) に直接アクセス権が付与されているため、フル アクセス権を持っています
direct_access
。
child access
ユーザー 1
$user1 = array(
'games' => array(
[1] => array(
'id' => 1,
'parent_access' => false,
'direct_access' => true,
'child_access' => false
)
),
'rounds' => array(
[1] => array(
'id' => 1,
'parent_access' => true,
'direct_access' => false,
'child_access' => false
)
),
'seasons' => array(
[1] => array(
'id' => 1,
'parent_access' => true,
'direct_access' => false,
'child_access' => false
),
),
'competitions' => array(
[1] => array(
'id' => 1,
'parent_access' => true,
'direct_access' => false,
'child_access' => false
),
)
);
ユーザー 2
$user2 = array(
'games' => array(
[1] => array(
'id' => 1,
'parent_access' => false,
'direct_access' => false,
'child_access' => true
),
[2] => array(
'id' => 2,
'parent_access' => false,
'direct_access' => false,
'child_access' => true
)
),
'rounds' => array(
[1] => array(
'id' => 1,
'parent_access' => false,
'direct_access' => true,
'child_access' => false
)
),
'seasons' => array(
[1] => array(
'id' => 1,
'parent_access' => true,
'direct_access' => false,
'child_access' => false
),
),
'competitions' => array(
[1] => array(
'id' => 1,
'parent_access' => true,
'direct_access' => false,
'child_access' => false
),
)
);
ユーザー 3
$user3 = array(
'games' => array(
[1] => array(
'id' => 1,
'parent_access' => false,
'direct_access' => false,
'child_access' => true
),
[2] => array(
'id' => 2,
'parent_access' => false,
'direct_access' => true,
'child_access' => true
),
[13] => array(
'id' => 13,
'parent_access' => false,
'direct_access' => true,
'child_access' => false
)
),
'rounds' => array(
[1] => array(
'id' => 1,
'parent_access' => false,
'direct_access' => true,
'child_access' => false
),
[7] => array(
'id' => 7,
'parent_access' => true,
'direct_access' => false,
'child_access' => false
)
),
'seasons' => array(
[1] => array(
'id' => 1,
'parent_access' => true,
'direct_access' => false,
'child_access' => false
),
[3] => array(
'id' => 3,
'parent_access' => true,
'direct_access' => false,
'child_access' => false
)
),
'competitions' => array(
[1] => array(
'id' => 1,
'parent_access' => true,
'direct_access' => false,
'child_access' => false
),
[2] => array(
'id' => 2,
'parent_access' => true,
'direct_access' => false,
'child_access' => false
)
)
);