-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimdb2_project.dbs
More file actions
2438 lines (1910 loc) · 96.6 KB
/
imdb2_project.dbs
File metadata and controls
2438 lines (1910 loc) · 96.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8" ?>
<project name="IMDB2" id="Project_5e99c03" template="Default" database="PostgreSQL" >
<schema name="imdb2" schemaname="imdb2" >
<table name="actors" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="person_id" type="integer" jt="4" mandatory="y" />
<column name="character/s" type="varchar" jt="12" mandatory="y" />
<index name="idx_actors_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_actors_person_id" unique="NORMAL" >
<column name="person_id" />
</index>
<fk name="fk_actors_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_actors_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
</table>
<table name="alternative_title" generator_rows="150" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="movie_title" type="integer" jt="4" mandatory="y" />
<index name="idx_alternative_title_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<fk name="fk_alternative_title_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
</table>
<table name="awards" generator_rows="100" >
<column name="award_name" type="varchar" jt="12" mandatory="y" />
<index name="pk_awards_awards_id" unique="PRIMARY_KEY" >
<column name="award_name" />
</index>
</table>
<table name="awards_categories" generator_rows="150" >
<column name="award_name" type="varchar" jt="12" mandatory="y" />
<column name="category_name" type="varchar" jt="12" mandatory="y" />
<index name="idx_awards_categories_award_id" unique="NORMAL" >
<column name="award_name" />
</index>
<index name="idx_awards_categories_category_id" unique="NORMAL" >
<column name="category_name" />
</index>
<fk name="fk_awards_categories_awards" to_schema="imdb2" to_table="awards" >
<fk_column name="award_name" pk="award_name" />
</fk>
<fk name="fk_awards_categories_awards_categories_names" to_schema="imdb2" to_table="awards_categories_names" >
<fk_column name="category_name" pk="category_name" />
</fk>
</table>
<table name="awards_categories_names" generator_rows="100" >
<column name="category_name" type="varchar" jt="12" mandatory="y" />
<column name="movie_or_person" type="char" length="1" jt="1" mandatory="y" >
<comment><![CDATA[M-movie
P-person
B-both]]></comment>
</column>
<index name="pk_awards_categories_names_category_id" unique="PRIMARY_KEY" >
<column name="category_name" />
</index>
</table>
<table name="cameraworkers" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="person_id" type="integer" jt="4" mandatory="y" />
<index name="idx_cameraworkers_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_cameraworkers_person_id" unique="NORMAL" >
<column name="person_id" />
</index>
<fk name="fk_cameraworkers_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_cameraworkers_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
</table>
<table name="categories" >
<column name="category" type="varchar" jt="12" mandatory="y" />
<column name="since" type="date" jt="91" mandatory="y" />
<column name="to" type="date" jt="91" >
<defo>current_date</defo>
</column>
<column name="movie_or_person" type="char" length="1" jt="1" />
<column name="category_genre" type="varchar" jt="12" />
<column name="category_role" type="varchar" jt="12" />
<column name="is_short" type="char" length="1" jt="1" />
<index name="pk_categories_category" unique="PRIMARY_KEY" >
<column name="category" />
</index>
</table>
<table name="citizenship" generator_rows="150" >
<column name="person_id" type="integer" jt="4" mandatory="y" />
<column name="country" type="integer" length="2" jt="4" mandatory="y" />
<index name="idx_citizenship_person_id" unique="NORMAL" >
<column name="person_id" />
</index>
<index name="idx_citizenship_country_id" unique="NORMAL" >
<column name="country" />
</index>
<fk name="fk_citizenship_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
<fk name="fk_citizenship_country" to_schema="imdb2" to_table="country" >
<fk_column name="country" pk="country_id" />
</fk>
</table>
<table name="company" >
<column name="company_id" type="integer" jt="4" mandatory="y" autoincrement="y" />
<column name="name" type="varchar" jt="12" mandatory="y" />
<index name="pk_company_company_id" unique="PRIMARY_KEY" >
<column name="company_id" />
</index>
</table>
<table name="composers" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="person_id" type="integer" jt="4" mandatory="y" />
<index name="idx_composers_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_composers_person_id" unique="NORMAL" >
<column name="person_id" />
</index>
<fk name="fk_composers_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_composers_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
</table>
<table name="country" >
<column name="country_id" type="integer" jt="4" mandatory="y" autoincrement="y" />
<column name="name" type="varchar" length="75" jt="12" mandatory="y" />
<index name="pk_country_country_id" unique="PRIMARY_KEY" >
<column name="country_id" />
</index>
</table>
<table name="crew" generator_rows="150" >
<column name="person_id" type="integer" jt="4" mandatory="y" />
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="role" type="integer" jt="4" mandatory="y" >
<comment><![CDATA[//Add enum:
{director,editor,music,cameraworker,writer,others}]]></comment>
</column>
<column name="character" type="integer" jt="4" >
<comment><![CDATA[//Add constraint
not null only if role == actor]]></comment>
</column>
<index name="idx_crew_person_id" unique="NORMAL" >
<column name="person_id" />
</index>
<index name="idx_crew_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<fk name="fk_crew_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
<fk name="fk_crew_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
</table>
<table name="description" generator_rows="150" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="description" type="text" jt="12" mandatory="y" />
<index name="pk_description_movie_id" unique="PRIMARY_KEY" >
<column name="movie_id" />
</index>
<fk name="fk_description_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
</table>
<table name="directors" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="person_id" type="integer" jt="4" mandatory="y" />
<index name="idx_directors_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_directors_person_id" unique="NORMAL" >
<column name="person_id" />
</index>
<fk name="fk_directors_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_directors_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
</table>
<table name="editors" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="person_id" type="integer" jt="4" mandatory="y" />
<index name="idx_editors_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_editors_person_id" unique="NORMAL" >
<column name="person_id" />
</index>
<fk name="fk_editors_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_editors_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
</table>
<table name="finance" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="budget" type="integer" length="0" decimal="2" jt="4" />
<column name="cumulative_gross" type="integer" jt="4" />
<column name="opening_weekend_usa" type="integer" jt="4" />
<index name="pk_finance_movie_id" unique="PRIMARY_KEY" >
<column name="movie_id" />
</index>
<fk name="fk_finance_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
</table>
<table name="genre" >
<column name="genre_id" type="integer" jt="4" mandatory="y" autoincrement="y" />
<column name="genre" type="varchar" length="30" jt="12" mandatory="y" />
<index name="pk_country_country_id_2" unique="PRIMARY_KEY" >
<column name="genre_id" />
</index>
</table>
<table name="language" >
<column name="language_id" type="integer" jt="4" mandatory="y" autoincrement="y" />
<column name="language" type="varchar" length="75" jt="12" mandatory="y" />
<index name="pk_country_country_id_0" unique="PRIMARY_KEY" >
<column name="language_id" />
</index>
</table>
<table name="movie" generator_rows="100" >
<column name="movie_id" type="integer" jt="4" mandatory="y" autoincrement="y" />
<column name="title" type="varchar" jt="12" mandatory="y" />
<column name="release_date" type="date" jt="91" />
<column name="runtime" type="cidr" jt="1111" mandatory="y" >
<comment><![CDATA[//Datatye interval]]></comment>
</column>
<column name="budget" type="integer" jt="4" />
<column name="boxoffice" type="integer" jt="4" />
<column name="opening_weekend_usa" type="integer" jt="4" />
<column name="description" type="text" jt="12" />
<index name="pk_movie_movie_id" unique="PRIMARY_KEY" >
<column name="movie_id" />
</index>
</table>
<table name="movie_awards" generator_rows="150" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="category" type="integer" jt="4" mandatory="y" />
<column name="nomination_or_win" type="char" length="1" jt="1" mandatory="y" >
<comment><![CDATA[N-Nomination
W-winner]]></comment>
</column>
<column name="year" type="date" jt="91" mandatory="y" >
<comment><![CDATA[//Datatype - Year]]></comment>
</column>
<index name="idx_awards_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_movie_awards_category" unique="NORMAL" >
<column name="category" />
</index>
<constraint name="nomination_or_win" >
<string>nomination_or_win='N' OR nomination_or_win='W'</string>
</constraint>
<fk name="fk_awards_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_movie_awards_awards" to_schema="imdb2" to_table="awards" />
<fk name="fk_movie_awards_awards_categories_names" to_schema="imdb2" to_table="awards_categories_names" >
<fk_column name="category" pk="category_name" />
</fk>
<fk name="fk_movie_awards_categories" to_schema="imdb2" to_table="categories" >
<fk_column name="category" pk="category" />
</fk>
</table>
<table name="movie_genre" generator_rows="150" >
<comment><![CDATA[//Add Enum]]></comment>
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="genre" type="varchar" jt="12" mandatory="y" />
<index name="idx_production_1_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_movie_genre_genre_id" unique="NORMAL" >
<column name="genre" />
</index>
<fk name="fk_production_1_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_movie_genre_genre" to_schema="imdb2" to_table="genre" >
<fk_column name="genre" pk="genre_id" />
</fk>
</table>
<table name="movie_language" generator_rows="150" >
<comment><![CDATA[//maybe add enum]]></comment>
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="language" type="integer" length="2" jt="4" mandatory="y" />
<index name="idx_movie_language_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_movie_language_language_id" unique="NORMAL" >
<column name="language" />
</index>
<fk name="fk_movie_language_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_movie_language_language" to_schema="imdb2" to_table="language" >
<fk_column name="language" pk="language_id" />
</fk>
</table>
<table name="movie_ranking" generator_rows="150" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="score" type="numeric" length="4" decimal="2" jt="2" mandatory="y" />
<column name="marks _quantity" type="integer" jt="4" mandatory="y" >
<comment><![CDATA[//Counted automatically]]></comment>
</column>
<index name="idx_movie_ranking_movie_id" unique="UNIQUE" >
<column name="movie_id" />
</index>
<index name="pk_movie_ranking_movie_id" unique="PRIMARY_KEY" >
<column name="movie_id" />
</index>
<fk name="fk_movie_ranking_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
</table>
<table name="movie_ratings" generator_rows="150" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="login" type="varchar" length="17" jt="12" mandatory="y" />
<column name="mark" type="integer" jt="4" mandatory="y" >
<comment><![CDATA[//Add enum {1,...,10}]]></comment>
</column>
<column name="heart" type="char" length="1" jt="1" >
<comment><![CDATA[H - heart]]></comment>
</column>
<column name="seen" type="date" jt="91" >
<defo>current_date</defo>
</column>
<index name="idx_movie_ratings_user_id" unique="NORMAL" >
<column name="login" />
</index>
<index name="idx_movie_ratings_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<fk name="fk_movie_ratings_users" to_schema="imdb2" to_table="users" >
<fk_column name="login" pk="login" />
</fk>
<fk name="fk_movie_ratings_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
</table>
<table name="others" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="person_id" type="integer" jt="4" mandatory="y" />
<index name="idx_others_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_others_person_id" unique="NORMAL" >
<column name="person_id" />
</index>
<fk name="fk_others_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_others_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
</table>
<table name="people" generator_rows="100" >
<column name="person_id" type="integer" jt="4" mandatory="y" autoincrement="y" />
<column name="first_name" type="varchar" jt="12" mandatory="y" />
<column name="last_name" type="varchar" jt="12" />
<column name="age" type="integer" jt="4" />
<column name="born" type="date" jt="91" />
<column name="died" type="date" jt="91" />
<column name="alive" type="char" length="1" jt="1" >
<comment><![CDATA[Y/N]]></comment>
</column>
<column name="birth_country" type="integer" length="2" jt="4" />
<index name="pk_people_person_id" unique="PRIMARY_KEY" >
<column name="person_id" />
</index>
<index name="idx_people_birth_country" unique="NORMAL" >
<column name="birth_country" />
</index>
<fk name="fk_people_country" to_schema="imdb2" to_table="country" >
<fk_column name="birth_country" pk="country_id" />
</fk>
</table>
<table name="people_awards" generator_rows="150" >
<column name="person_id" type="integer" jt="4" mandatory="y" />
<column name="movie_id" type="integer" jt="4" />
<column name="category" type="integer" jt="4" mandatory="y" />
<column name="nomination_or_win" type="char" length="1" jt="1" mandatory="y" >
<comment><![CDATA[N-Nomination
W-Win]]></comment>
</column>
<column name="year" type="date" jt="91" mandatory="y" />
<index name="idx_people_awards_person_id" unique="NORMAL" >
<column name="person_id" />
</index>
<index name="idx_people_awards_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_people_awards_category" unique="NORMAL" >
<column name="category" />
</index>
<fk name="fk_people_awards_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
<fk name="fk_people_awards_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_people_awards_awards" to_schema="imdb2" to_table="awards" />
<fk name="fk_people_awards_awards_categories_names" to_schema="imdb2" to_table="awards_categories_names" >
<fk_column name="category" pk="category_name" />
</fk>
<fk name="fk_people_awards_categories" to_schema="imdb2" to_table="categories" >
<fk_column name="category" pk="category" />
</fk>
</table>
<table name="people_ranking" generator_rows="225" >
<column name="person_id" type="integer" jt="4" mandatory="y" />
<column name="score" type="numeric" length="4" decimal="2" jt="2" />
<column name="marks_quantity" type="integer" jt="4" mandatory="y" >
<comment><![CDATA[//Counted automatically]]></comment>
</column>
<index name="pk_people_ranking_person_id" unique="PRIMARY_KEY" >
<column name="person_id" />
</index>
<fk name="fk_people_ranking_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
</table>
<table name="person_ratings" generator_rows="150" >
<comment><![CDATA[/Add enum {1,...,10}]]></comment>
<column name="person_id" type="integer" jt="4" mandatory="y" />
<column name="login" type="varchar" length="17" jt="12" mandatory="y" />
<column name="mark" type="integer" jt="4" mandatory="y" />
<column name="heart" type="char" length="1" jt="1" >
<comment><![CDATA[H - heart]]></comment>
</column>
<index name="idx_person_ratings_user_id" unique="NORMAL" >
<column name="login" />
</index>
<index name="idx_person_ratings_person_id" unique="NORMAL" >
<column name="person_id" />
</index>
<fk name="fk_person_ratings_users" to_schema="imdb2" to_table="users" >
<fk_column name="login" pk="login" />
</fk>
<fk name="fk_person_ratings_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
</table>
<table name="production" generator_rows="150" >
<comment><![CDATA[//Maybe add enum]]></comment>
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="country" type="varchar" jt="12" mandatory="y" />
<index name="idx_production_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_production_country_id" unique="NORMAL" >
<column name="country" />
</index>
<fk name="fk_production_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_production_country" to_schema="imdb2" to_table="country" >
<fk_column name="country" pk="country_id" />
</fk>
</table>
<table name="production_company" generator_rows="150" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="company" type="varchar" jt="12" mandatory="y" />
<index name="idx_production_company_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_production_company_company_id" unique="NORMAL" >
<column name="company" />
</index>
<fk name="fk_production_company_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_production_company_company" to_schema="imdb2" to_table="company" >
<fk_column name="company" pk="company_id" />
</fk>
</table>
<table name="profession" generator_rows="150" >
<column name="person_id" type="integer" jt="4" mandatory="y" />
<column name="profession" type="varchar" jt="12" />
<index name="idx_profession_person_id" unique="NORMAL" >
<column name="person_id" />
</index>
<fk name="fk_profession_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
<fk name="fk_profession_professions" to_schema="imdb2" to_table="professions" />
</table>
<table name="profession_0" >
<column name="person_id" type="integer" jt="4" mandatory="y" />
<column name="profession" type="varchar" jt="12" mandatory="y" />
<index name="idx_profession_person_id_0" unique="NORMAL" >
<column name="person_id" />
</index>
<index name="idx_profession_profession_id_0" unique="NORMAL" >
<column name="profession" />
</index>
</table>
<table name="professions" >
<column name="profession_id" type="integer" jt="4" mandatory="y" autoincrement="y" />
<column name="name" type="varchar" jt="12" mandatory="y" />
<index name="pk_professions_profession_id" unique="PRIMARY_KEY" >
<column name="profession_id" />
</index>
</table>
<table name="review" generator_rows="150" >
<column name="login" type="varchar" length="17" jt="12" mandatory="y" />
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="review" type="text" jt="12" mandatory="y" />
<index name="idx_review_user_id" unique="NORMAL" >
<column name="login" />
</index>
<index name="idx_review_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<fk name="fk_review_users" to_schema="imdb2" to_table="users" >
<fk_column name="login" pk="login" />
</fk>
<fk name="fk_review_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
</table>
<table name="similar_movies" generator_rows="150" >
<column name="movie_id1" type="integer" jt="4" mandatory="y" />
<column name="movie_id2" type="integer" jt="4" mandatory="y" />
<index name="idx_similar_movies_movie_id1" unique="NORMAL" >
<column name="movie_id1" />
</index>
<index name="idx_similar_movies_movie_id2" unique="NORMAL" >
<column name="movie_id2" />
</index>
<fk name="fk_similar_movies_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id1" pk="movie_id" />
</fk>
<fk name="fk_similar_movies_movie_0" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id2" pk="movie_id" />
</fk>
</table>
<table name="table" />
<table name="table_2" />
<table name="users" generator_rows="100" >
<column name="login" type="varchar" length="17" jt="12" mandatory="y" />
<column name="password" type="varchar" length="1024" jt="12" mandatory="y" >
<comment><![CDATA[hash]]></comment>
</column>
<index name="pk_users_users_id" unique="PRIMARY_KEY" >
<column name="login" />
</index>
</table>
<table name="watchlist" generator_rows="150" >
<column name="login" type="char" length="17" jt="1" mandatory="y" />
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<index name="idx_watchlist_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_watchlist_user_id" unique="NORMAL" >
<column name="login" />
</index>
<fk name="fk_watchlist_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_watchlist_users" to_schema="imdb2" to_table="users" >
<fk_column name="login" pk="login" />
</fk>
</table>
<table name="writers" >
<column name="movie_id" type="integer" jt="4" mandatory="y" />
<column name="person_id" type="integer" jt="4" mandatory="y" />
<index name="idx_writers_movie_id" unique="NORMAL" >
<column name="movie_id" />
</index>
<index name="idx_writers_person_id" unique="NORMAL" >
<column name="person_id" />
</index>
<fk name="fk_writers_movie" to_schema="imdb2" to_table="movie" >
<fk_column name="movie_id" pk="movie_id" />
</fk>
<fk name="fk_writers_people" to_schema="imdb2" to_table="people" >
<fk_column name="person_id" pk="person_id" />
</fk>
</table>
</schema>
<connector name="PostgreSQL" database="PostgreSQL" driver_class="org.postgresql.Driver" driver_jar="postgresql-42.2.2.jar" driver_desc="Heroku" host="localhost" port="5432" instance="postgres" user="postgres" timezone="Europe/Warsaw" read_only="y" />
<layout name="Default Layout" id="Layout_c9c525" show_relation="columns" >
<comment><![CDATA[IMDB2]]></comment>
<entity schema="imdb2" name="alternative_title" color="330033" x="208" y="112" />
<entity schema="imdb2" name="production_company" color="00FF00" x="288" y="480" />
<entity schema="imdb2" name="crew" color="00FF00" x="784" y="384" />
<entity schema="imdb2" name="production" color="00FF00" x="112" y="240" />
<entity schema="imdb2" name="movie_genre" color="00FF00" x="128" y="432" />
<entity schema="imdb2" name="movie_language" color="00FF00" x="96" y="336" />
<entity schema="imdb2" name="movie" color="FF0000" x="432" y="256" />
<entity schema="imdb2" name="similar_movies" color="C1D8EE" x="448" y="64" />
<entity schema="imdb2" name="watchlist" color="00FF00" x="224" y="672" />
<entity schema="imdb2" name="review" color="FF00FF" x="48" y="656" />
<entity schema="imdb2" name="person_ratings" color="00FF00" x="688" y="608" />
<entity schema="imdb2" name="people" color="FF0000" x="1040" y="496" />
<entity schema="imdb2" name="people_awards" color="00FF00" x="992" y="256" />
<entity schema="imdb2" name="movie_awards" color="00FF00" x="720" y="48" />
<entity schema="imdb2" name="profession" color="00FF00" x="912" y="816" />
<entity schema="imdb2" name="movie_ratings" color="00FF00" x="512" y="624" />
<entity schema="imdb2" name="users" color="FF0000" x="560" y="848" />
<entity schema="imdb2" name="categories" color="800000" x="944" y="48" />
<script name="SQL_Editor" id="Editor_28d9917" language="SQL" >
<string><![CDATA[CREATE SCHEMA imdb2;
CREATE TABLE awards (
award_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
award_name varchar NOT NULL ,
CONSTRAINT pk_awards_awards_id PRIMARY KEY ( award_id )
);
CREATE TABLE awards_categories_names (
category_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
category_name varchar NOT NULL ,
movie_or_person char(1) NOT NULL ,
CONSTRAINT pk_awards_categories_names_category_id PRIMARY KEY ( category_id )
CHECK (movie_or_person = 'M' OR movie_or_person = 'P' OR movie_or_person = 'N')
);
COMMENT ON COLUMN awards_categories_names.movie_or_person IS 'M-movie\nP-person\nB-both';
CREATE TABLE company (
company_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
name varchar NOT NULL ,
CONSTRAINT pk_company_company_id PRIMARY KEY ( company_id )
);
CREATE TABLE country (
country_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
name varchar(75) NOT NULL ,
CONSTRAINT pk_country_country_id PRIMARY KEY ( country_id )
);
CREATE TABLE genre (
genre_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
genre varchar(30) NOT NULL ,
CONSTRAINT pk_country_country_id_2 PRIMARY KEY ( genre_id )
);
CREATE TABLE "language" (
language_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"language" varchar(75) NOT NULL ,
CONSTRAINT pk_country_country_id_0 PRIMARY KEY ( language_id )
);
CREATE TABLE movie (
movie_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
title varchar NOT NULL ,
release_date date ,
production_date date ,
runtime cidr NOT NULL ,
budget integer ,
cumulative_gross integer ,
opening_weekend_usa integer ,
CONSTRAINT pk_movie_movie_id PRIMARY KEY ( movie_id )
);
COMMENT ON COLUMN movie.production_date IS '//Datatype year';
COMMENT ON COLUMN movie.runtime IS '//Datatye interval';
CREATE TABLE movie_awards (
movie_id integer NOT NULL ,
awards_id integer NOT NULL ,
category integer ,
nomination_or_win char(1) NOT NULL ,
"year" date NOT NULL ,
CONSTRAINT fk_awards_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_movie_awards_awards FOREIGN KEY ( awards_id ) REFERENCES awards( award_id )
);
ALTER TABLE movie_awards ADD CONSTRAINT nomination_or_win CHECK ( nomination_or_win='N' OR nomination_or_win='W' );
CREATE INDEX idx_awards_movie_id ON movie_awards ( movie_id );
CREATE INDEX idx_movie_awards_awards_id ON movie_awards ( awards_id );
COMMENT ON COLUMN movie_awards.nomination_or_win IS 'N-Nomination\nW-winner';
COMMENT ON COLUMN movie_awards."year" IS '//Datatype - Year';
CREATE TABLE movie_genre (
movie_id integer NOT NULL ,
genre varchar NOT NULL ,
CONSTRAINT fk_production_1_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_movie_genre_genre FOREIGN KEY ( genre ) REFERENCES genre( genre_id )
);
CREATE INDEX idx_production_1_movie_id ON movie_genre ( movie_id );
CREATE INDEX idx_movie_genre_genre_id ON movie_genre ( genre );
COMMENT ON TABLE movie_genre IS '//Add Enum';
CREATE TABLE movie_language (
movie_id integer NOT NULL ,
"language" integer NOT NULL ,
CONSTRAINT fk_movie_language_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_movie_language_language FOREIGN KEY ( "language" ) REFERENCES "language"( language_id )
);
CREATE INDEX idx_movie_language_movie_id ON movie_language ( movie_id );
CREATE INDEX idx_movie_language_language_id ON movie_language ( "language" );
COMMENT ON TABLE movie_language IS '//maybe add enum';
CREATE TABLE movie_ranking (
movie_id integer NOT NULL ,
score numeric(4,2) NOT NULL ,
"marks _quantity" integer NOT NULL ,
CONSTRAINT idx_movie_ranking_movie_id UNIQUE ( movie_id ) ,
CONSTRAINT pk_movie_ranking_movie_id PRIMARY KEY ( movie_id ),
CONSTRAINT fk_movie_ranking_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id )
);
COMMENT ON COLUMN movie_ranking."marks _quantity" IS '//Counted automatically';
CREATE TABLE people (
person_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
first_name varchar NOT NULL ,
last_name varchar ,
age integer ,
born date ,
died date ,
alive char(1) ,
birth_country integer ,
CONSTRAINT pk_people_person_id PRIMARY KEY ( person_id ),
CONSTRAINT fk_people_country FOREIGN KEY ( birth_country ) REFERENCES country( country_id )
);
CREATE INDEX idx_people_birth_country ON people ( birth_country );
COMMENT ON COLUMN people.alive IS 'Y/N';
CREATE TABLE people_awards (
person_id integer NOT NULL ,
award_id integer NOT NULL ,
movie_id integer ,
category integer ,
nomination_or_win char(1) NOT NULL ,
"year" date NOT NULL ,
CONSTRAINT idx_people_awards_person_id UNIQUE ( person_id ) ,
CONSTRAINT fk_people_awards_people FOREIGN KEY ( person_id ) REFERENCES people( person_id ) ,
CONSTRAINT fk_people_awards_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_people_awards_awards FOREIGN KEY ( award_id ) REFERENCES awards( award_id )
);
CREATE INDEX idx_people_awards_movie_id ON people_awards ( movie_id );
CREATE INDEX idx_people_awards_award_id ON people_awards ( award_id );
COMMENT ON COLUMN people_awards.nomination_or_win IS 'N-Nomination\nW-Win';
CREATE TABLE people_ranking (
person_id integer NOT NULL ,
score numeric(4,2) ,
marks_quantity integer NOT NULL ,
CONSTRAINT pk_people_ranking_person_id PRIMARY KEY ( person_id ),
CONSTRAINT fk_people_ranking_people_awards FOREIGN KEY ( person_id ) REFERENCES people_awards( person_id )
);
COMMENT ON COLUMN people_ranking.marks_quantity IS '//Counted automatically';
CREATE TABLE production (
movie_id integer NOT NULL ,
country varchar NOT NULL ,
CONSTRAINT fk_production_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_production_country FOREIGN KEY ( country ) REFERENCES country( country_id )
);
CREATE INDEX idx_production_movie_id ON production ( movie_id );
CREATE INDEX idx_production_country_id ON production ( country );
COMMENT ON TABLE production IS '//Maybe add enum';
CREATE TABLE production_company (
movie_id integer NOT NULL ,
company varchar NOT NULL ,
CONSTRAINT fk_production_company_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_production_company_company FOREIGN KEY ( company ) REFERENCES company( company_id )
);
CREATE INDEX idx_production_company_movie_id ON production_company ( movie_id );
CREATE INDEX idx_production_company_company_id ON production_company ( company );
CREATE TABLE professions (
profession_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
name varchar NOT NULL ,
CONSTRAINT pk_professions_profession_id PRIMARY KEY ( profession_id )
);
CREATE TABLE similar_movies (
movie_id1 integer NOT NULL ,
movie_id2 integer NOT NULL ,
CONSTRAINT fk_similar_movies_movie FOREIGN KEY ( movie_id1 ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_similar_movies_movie_0 FOREIGN KEY ( movie_id2 ) REFERENCES movie( movie_id )
);
CREATE INDEX idx_similar_movies_movie_id1 ON similar_movies ( movie_id1 );
CREATE INDEX idx_similar_movies_movie_id2 ON similar_movies ( movie_id2 );
CREATE TABLE "table" (
);
CREATE TABLE table_2 (
);
CREATE TABLE users (
users_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
login varchar(17) NOT NULL ,
"password" varchar(17) NOT NULL ,
nickname varchar(17) DEFAULT user ,
CONSTRAINT pk_users_users_id PRIMARY KEY ( users_id )
);
CREATE TABLE watchlist (
user_id integer NOT NULL ,
movie_id integer NOT NULL ,
CONSTRAINT fk_watchlist_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_watchlist_users FOREIGN KEY ( user_id ) REFERENCES users( users_id )
);
CREATE INDEX idx_watchlist_movie_id ON watchlist ( movie_id );
CREATE INDEX idx_watchlist_user_id ON watchlist ( user_id );
CREATE TABLE writers (
movie_id integer NOT NULL ,
person_id integer NOT NULL ,
CONSTRAINT fk_writers_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_writers_people FOREIGN KEY ( person_id ) REFERENCES people( person_id )
);
CREATE INDEX idx_writers_movie_id ON writers ( movie_id );
CREATE INDEX idx_writers_person_id ON writers ( person_id );
CREATE TABLE actors (
movie_id integer NOT NULL ,
person_id integer NOT NULL ,
"character/s" varchar NOT NULL ,
CONSTRAINT fk_actors_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_actors_people FOREIGN KEY ( person_id ) REFERENCES people( person_id )
);
CREATE INDEX idx_actors_movie_id ON actors ( movie_id );
CREATE INDEX idx_actors_person_id ON actors ( person_id );
CREATE TABLE alternative_title (
movie_id integer NOT NULL ,
movie_title integer NOT NULL ,
CONSTRAINT fk_alternative_title_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id )
);
CREATE INDEX idx_alternative_title_movie_id ON alternative_title ( movie_id );
CREATE TABLE awards_categories (
award_id integer NOT NULL ,
category_id integer NOT NULL ,
CONSTRAINT fk_awards_categories_awards FOREIGN KEY ( award_id ) REFERENCES awards( award_id ) ,
CONSTRAINT fk_awards_categories_awards_categories_names FOREIGN KEY ( category_id ) REFERENCES awards_categories_names( category_id )
);
CREATE INDEX idx_awards_categories_award_id ON awards_categories ( award_id );
CREATE INDEX idx_awards_categories_category_id ON awards_categories ( category_id );
CREATE TABLE cameraworkers (
movie_id integer NOT NULL ,
person_id integer NOT NULL ,
CONSTRAINT fk_cameraworkers_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_cameraworkers_people FOREIGN KEY ( person_id ) REFERENCES people( person_id )
);
CREATE INDEX idx_cameraworkers_movie_id ON cameraworkers ( movie_id );
CREATE INDEX idx_cameraworkers_person_id ON cameraworkers ( person_id );
CREATE TABLE citizenship (
person_id integer NOT NULL ,
country integer NOT NULL ,
CONSTRAINT fk_citizenship_people FOREIGN KEY ( person_id ) REFERENCES people( person_id ) ,
CONSTRAINT fk_citizenship_country FOREIGN KEY ( country ) REFERENCES country( country_id )
);
CREATE INDEX idx_citizenship_person_id ON citizenship ( person_id );
CREATE INDEX idx_citizenship_country_id ON citizenship ( country );
CREATE TABLE composers (
movie_id integer NOT NULL ,
person_id integer NOT NULL ,
CONSTRAINT fk_composers_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_composers_people FOREIGN KEY ( person_id ) REFERENCES people( person_id )
);
CREATE INDEX idx_composers_movie_id ON composers ( movie_id );
CREATE INDEX idx_composers_person_id ON composers ( person_id );
CREATE TABLE crew (
person_id integer NOT NULL ,
movie_id integer NOT NULL ,
"role" integer NOT NULL ,
"character" integer ,
CONSTRAINT fk_crew_people FOREIGN KEY ( person_id ) REFERENCES people( person_id ) ,
CONSTRAINT fk_crew_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id )
);
CREATE INDEX idx_crew_person_id ON crew ( person_id );
CREATE INDEX idx_crew_movie_id ON crew ( movie_id );
COMMENT ON COLUMN crew."role" IS '//Add enum:\n{director,editor,music,cameraworker,writer,others}';
COMMENT ON COLUMN crew."character" IS '//Add constraint\nnot null only if role == actor';
CREATE TABLE description (
movie_id integer NOT NULL ,
description text NOT NULL ,
CONSTRAINT pk_description_movie_id PRIMARY KEY ( movie_id ),
CONSTRAINT fk_description_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id )
);
CREATE TABLE directors (
movie_id integer NOT NULL ,
person_id integer NOT NULL ,
CONSTRAINT fk_directors_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_directors_people FOREIGN KEY ( person_id ) REFERENCES people( person_id )
);
CREATE INDEX idx_directors_movie_id ON directors ( movie_id );
CREATE INDEX idx_directors_person_id ON directors ( person_id );
CREATE TABLE editors (
movie_id integer NOT NULL ,
person_id integer NOT NULL ,
CONSTRAINT fk_editors_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_editors_people FOREIGN KEY ( person_id ) REFERENCES people( person_id )
);
CREATE INDEX idx_editors_movie_id ON editors ( movie_id );
CREATE INDEX idx_editors_person_id ON editors ( person_id );
CREATE TABLE finance (
movie_id integer NOT NULL ,
budget integer ,
cumulative_gross integer ,
opening_weekend_usa integer ,
CONSTRAINT pk_finance_movie_id PRIMARY KEY ( movie_id ),
CONSTRAINT fk_finance_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id )
);
CREATE TABLE movie_ratings (
movie_id integer NOT NULL ,
user_id integer NOT NULL ,
mark integer NOT NULL ,
heart char(1) ,
CONSTRAINT fk_movie_ratings_users FOREIGN KEY ( user_id ) REFERENCES users( users_id ) ,
CONSTRAINT fk_movie_ratings_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id )
);
CREATE INDEX idx_movie_ratings_user_id ON movie_ratings ( user_id );
CREATE INDEX idx_movie_ratings_movie_id ON movie_ratings ( movie_id );
COMMENT ON COLUMN movie_ratings.mark IS '//Add enum {1,...,10}';
COMMENT ON COLUMN movie_ratings.heart IS 'H - heart';
CREATE TABLE others (
movie_id integer NOT NULL ,
person_id integer NOT NULL ,
CONSTRAINT fk_others_movie FOREIGN KEY ( movie_id ) REFERENCES movie( movie_id ) ,
CONSTRAINT fk_others_people FOREIGN KEY ( person_id ) REFERENCES people( person_id )
);
CREATE INDEX idx_others_movie_id ON others ( movie_id );
CREATE INDEX idx_others_person_id ON others ( person_id );
CREATE TABLE person_ratings (