mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 15:43:16 +02:00
random passing entities
This commit is contained in:
parent
417d6f714c
commit
ba73e56213
@ -6,7 +6,22 @@ alter table club
|
||||
alter table club
|
||||
DISABLE constraint club_competition_fk;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
alter table takes_part_in
|
||||
add id number;
|
||||
|
||||
where exists C
|
||||
select * from takes_part_in
|
||||
where club_id = match_id and club_id
|
||||
|
||||
alter table takes_part_in
|
||||
drop column id
|
||||
|
||||
|
||||
|
||||
|
||||
alter table manager
|
||||
ENABLE constraint manager_club_fk;
|
||||
|
||||
|
||||
@ -1,10 +1,3 @@
|
||||
--variable loops number
|
||||
--loops := 10;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
truncate table takes_part_in cascade;--
|
||||
truncate table takes_place_in cascade;--
|
||||
truncate table player cascade;--
|
||||
@ -14,7 +7,7 @@ truncate table manager cascade;--
|
||||
truncate table club cascade;--
|
||||
truncate table competition cascade;--competition is last since it has no foreign keys (but club holds a foreign key to competition)
|
||||
|
||||
declare loops number := 20;
|
||||
declare loops number := 10;
|
||||
begin
|
||||
|
||||
--create table countryTable (Cname varchar(20))
|
||||
@ -111,20 +104,34 @@ insert into player
|
||||
connect by level <=loops
|
||||
;
|
||||
|
||||
insert into takes_part_in
|
||||
select
|
||||
dbms_random.value(1,loops) as club_id,
|
||||
dbms_random.value(1,loops) as match_id
|
||||
from dual
|
||||
connect by level <=loops
|
||||
;
|
||||
--insert into takes_part_in
|
||||
-- select club.id, match.id from club, match;--creates a table 1-1 everything into everything
|
||||
|
||||
insert into takes_part_in
|
||||
SELECT club_id, match_id
|
||||
FROM (
|
||||
SELECT club.id as club_id, match.id as match_id
|
||||
FROM club, match
|
||||
ORDER BY DBMS_RANDOM.RANDOM)
|
||||
WHERE rownum < 11;
|
||||
|
||||
insert into takes_place_in
|
||||
select
|
||||
dbms_random.value(1,loops) as stadium_id,
|
||||
dbms_random.value(1,loops) as competition_id
|
||||
from dual
|
||||
connect by level <=loops
|
||||
;
|
||||
--insert into takes_part_in
|
||||
-- select
|
||||
-- dbms_random.value(1,loops) as club_id,
|
||||
-- dbms_random.value(1,loops) as match_id
|
||||
-- from dual
|
||||
--connect by level <=loops
|
||||
--;
|
||||
|
||||
--insert into takes_place_in
|
||||
-- select stadium.id, competition.id from stadium, competition ORDER BY DBMS_RANDOM.RANDOM limit 10;
|
||||
|
||||
--insert into takes_place_in
|
||||
-- select
|
||||
-- dbms_random.value(1,loops) as stadium_id,
|
||||
-- dbms_random.value(1,loops) as competition_id
|
||||
-- from dual
|
||||
--connect by level <=loops
|
||||
--;
|
||||
|
||||
end;
|
||||
Loading…
Reference in New Issue
Block a user