mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-06 16:43:01 +02:00
working randomization
This commit is contained in:
parent
ba73e56213
commit
143f2ac566
@ -7,7 +7,9 @@ truncate table manager cascade;--
|
|||||||
truncate table club 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)
|
truncate table competition cascade;--competition is last since it has no foreign keys (but club holds a foreign key to competition)
|
||||||
|
|
||||||
declare loops number := 10;
|
declare loops number := 50;
|
||||||
|
begin
|
||||||
|
declare many_to_many number := 15;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
--create table countryTable (Cname varchar(20))
|
--create table countryTable (Cname varchar(20))
|
||||||
@ -113,7 +115,7 @@ insert into takes_part_in
|
|||||||
SELECT club.id as club_id, match.id as match_id
|
SELECT club.id as club_id, match.id as match_id
|
||||||
FROM club, match
|
FROM club, match
|
||||||
ORDER BY DBMS_RANDOM.RANDOM)
|
ORDER BY DBMS_RANDOM.RANDOM)
|
||||||
WHERE rownum < 11;
|
WHERE rownum <= many_to_many;
|
||||||
|
|
||||||
--insert into takes_part_in
|
--insert into takes_part_in
|
||||||
-- select
|
-- select
|
||||||
@ -126,6 +128,14 @@ insert into takes_part_in
|
|||||||
--insert into takes_place_in
|
--insert into takes_place_in
|
||||||
-- select stadium.id, competition.id from stadium, competition ORDER BY DBMS_RANDOM.RANDOM limit 10;
|
-- select stadium.id, competition.id from stadium, competition ORDER BY DBMS_RANDOM.RANDOM limit 10;
|
||||||
|
|
||||||
|
insert into takes_place_in
|
||||||
|
SELECT stadium_id, competition_id
|
||||||
|
FROM (
|
||||||
|
SELECT stadium.id as stadium_id, competition.id as competition_id
|
||||||
|
FROM stadium, competition
|
||||||
|
ORDER BY DBMS_RANDOM.RANDOM)
|
||||||
|
WHERE rownum <= many_to_many;
|
||||||
|
|
||||||
--insert into takes_place_in
|
--insert into takes_place_in
|
||||||
-- select
|
-- select
|
||||||
-- dbms_random.value(1,loops) as stadium_id,
|
-- dbms_random.value(1,loops) as stadium_id,
|
||||||
@ -135,3 +145,4 @@ insert into takes_part_in
|
|||||||
--;
|
--;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
Loading…
Reference in New Issue
Block a user