结构化查询语言SQL

之前的关系代数属于过程化语言,同时指定了具体计算过程。关系型语言仅仅指明用户需要什么数据,而不指定具体计算过程,由数据库管理系统负责底层的具体实现。

关系型语言一般由以下几个部分组成:

  • 数据定义语言(data definition language)
  • 数据操纵语言(data manipulation language)
  • 数据控制语言(data control language)

其中结构化查询语言SQL广泛使用。

另外,关系代数基于集合,即无序,无重复,而关系型查询语言基于多集,即无序,允许重复。

以下为homework1的解析

homework1中的数据集IMDB是一个关于电影、电视节目、电子游戏和电影制作小组的在线数据库。本次howework中的sql由sqlite实现。

首先创建sql文件,每个sql文件对应于hw中的一个问题。

1
2
3
4
5
6
7
8
9
10
11
12
$ mkdir placeholder
$ cd placeholder
$ touch q1_sample.sql \
q2_uncommon_type.sql \
q3_tv_vs_movie.sql \
q4_old_is_not_gold.sql \
q5_percentage.sql \
q6_dubbed_smash.sql \
q7_imdb_250.sql \
q8_number_of_actors.sql \
q9_movie_names.sql \
q10_genre_counts.sql

安装sqlite和libsqlite3-dev

1
sudo apt-get install sqlite3 libsqlite3-dev

下载imdb数据库压缩包

1
$ wget https://15445.courses.cs.cmu.edu/fall2019/files/imdb-cmudb2019.db.gz

校验md5校验和

1
2
$ md5 imdb-cmudb2019.db.gz 
MD5 (imdb-cmudb2019.db.gz) = 6443351d4b55eb3c881622bd60a8dc5b

解压数据库压缩包并用sqlite打开

1
2
$ gunzip imdb-cmudb2019.db.gz
$ sqlite3 imdb-cmudb2019.db

查看数据库中的表

1
2
sqlite> .tables
akas crew episodes people ratings titles

为每个表创建索引

1
2
3
4
5
6
7
8
CREATE INDEX ix_people_name ON people (name);
CREATE INDEX ix_titles_type ON titles (type);
CREATE INDEX ix_titles_primary_title ON titles (primary_title);
CREATE INDEX ix_titles_original_title ON titles (original_title);
CREATE INDEX ix_akas_title_id ON akas (title_id);
CREATE INDEX ix_akas_title ON akas (title);
CREATE INDEX ix_crew_title_id ON crew (title_id);
CREATE INDEX ix_crew_person_id ON crew (person_id);

检查数据库模式

people表的属性有身份证号,名字,出生日期,死亡日期,索引为姓名。

1
2
3
4
5
6
7
8
sqlite> .schema people
CREATE TABLE people (
person_id VARCHAR PRIMARY KEY,
name VARCHAR,
born INTEGER,
died INTEGER
);
CREATE INDEX ix_people_name ON people (name);

其中的一项为

1
nm0000003|Brigitte Bardot|1934|

title表为电影/电视剧/短视频/视频的具体信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sqlite> .schema titles
CREATE TABLE titles (
title_id VARCHAR PRIMARY KEY,
type VARCHAR,
primary_title VARCHAR,
original_title VARCHAR,
is_adult INTEGER,
premiered INTEGER,
ended INTEGER,
runtime_minutes INTEGER,
genres VARCHAR
);
CREATE INDEX ix_titles_type ON titles (type);
CREATE INDEX ix_titles_primary_title ON titles (primary_title);
CREATE INDEX ix_titles_original_title ON titles (original_title);

akas表为标题的语言,地区等信息,上映电影在其余国家的信息,标题可能会翻译成上映国家的版本。

1
2
3
4
5
6
7
8
9
10
11
CREATE TABLE akas (
title_id VARCHAR, -- REFERENCES titles (title_id),
title VARCHAR,
region VARCHAR,
language VARCHAR,
types VARCHAR,
attributes VARCHAR,
is_original_title INTEGER
);
CREATE INDEX ix_akas_title_id ON akas (title_id);
CREATE INDEX ix_akas_title ON akas (title);

crew表为某剧对应的人物信息。

1
2
3
4
5
6
7
8
CREATE TABLE crew (
title_id VARCHAR, -- REFERENCES titles (title_id),
person_id VARCHAR, -- REFERENCES people (person_id),
category VARCHAR,
job VARCHAR
);
CREATE INDEX ix_crew_title_id ON crew (title_id);
CREATE INDEX ix_crew_person_id ON crew (person_id);

其中一行的信息为

1
tt0000003|nm5442194|producer|producer

rating表为对应的id和评分,参与人数

1
2
3
4
5
CREATE TABLE ratings (
title_id VARCHAR PRIMARY KEY, -- REFERENCES titles (title_id),
rating FLOAT,
votes INTEGER
);

其中一行的信息为

1
tt0000001|5.6|1529

q1

查询titles表中不同类型有哪些

1
2
3
4
5
6
7
8
9
10
11
sqlite> select distinct(type) from titles order by type;
movie
short
tvEpisode
tvMiniSeries
tvMovie
tvSeries
tvShort
tvSpecial
video
videoGame

q2

查询每种类型中最长播放时间的title

  • 对于存在并列的情况,所有并列的条目均输出
  • 输出types,primary titles,runtime minutes,按照type升序,若type相同则按照primary titles升序

简单地,查询每种类型中最长播放时间

1
SELECT type,max(runtime_minutes) FROM titles GROUP BY type;

得到

1
2
3
4
5
6
7
8
9
10
movie|51420
short|461
tvEpisode|1800
tvMiniSeries|1755
tvMovie|2112
tvSeries|8400
tvShort|60
tvSpecial|5760
video|5135
videoGame|1500

查询目标为runtime_minutes等于最大值的title

1
2
3
4
5
6
7
8
9
10
11
WITH types(type, runtime_minutes) AS ( 
SELECT type, MAX(runtime_minutes)
FROM titles
GROUP BY type
)
SELECT titles.type, titles.primary_title, titles.runtime_minutes
FROM titles
JOIN types
ON titles.runtime_minutes == types.runtime_minutes AND titles.type == types.type
ORDER BY titles.type, titles.primary_title
;

可通过with子句定义临时关系,再通过join运算限定title条目。

查询结果如下

1
2
3
4
5
6
7
8
9
10
11
movie|Logistics|51420
short|Kuriocity|461
tvEpisode|Téléthon 2012|1800
tvMiniSeries|Kôya no yôjinbô|1755
tvMovie|ArtQuench Presents Spirit Art|2112
tvSeries|The Sharing Circle|8400
tvShort|Paul McCartney Backstage at Super Bowl XXXIX|60
tvShort|The People Next Door|60
tvSpecial|Katy Perry Live: Witness World Wide|5760
video|Midnight Movie Madness: 50 Movie Mega Pack|5135
videoGame|Flushy Fish VR: Just Squidding Around|1500

q3

列出所有类型的title,并给出相关条目的数量

  • 按照类型升序
1
SELECT type, count(*) AS title_count FROM titles GROUP BY type ORDER BY title_count ASC;

查询结果如下

1
2
3
4
5
6
7
8
9
10
tvShort|4075
videoGame|9044
tvSpecial|9107
tvMiniSeries|10291
tvMovie|45431
tvSeries|63631
video|90069
movie|197957
short|262038
tvEpisode|1603076

q4

按照每十年为间隔,统计首映的titles数目,例如2010s|2789741

  • 年份按照类似2010s的格式输出,按照数目降序,premieredNULL的条目不计入结果

通过group by子句按照每十年分组,通过字符串运算在年份后添加s

1
2
3
4
5
6
7
8
SELECT 
CAST(premiered/10*10 AS TEXT) || 's' AS decade,
COUNT(*) AS num_movies
FROM titles
WHERE premiered is not null
GROUP BY decade
ORDER BY num_movies DESC
;

查询结果如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2010s|1050732
2000s|494639
1990s|211453
1980s|119258
1970s|99707
1960s|75237
1950s|39554
1910s|26596
1920s|13153
1930s|11492
1940s|10011
1900s|9586
2020s|2492
1890s|2286
1880s|22
1870s|1

q5

按照每十年为间隔,统计对应首映的titles数目百分比,例如 2010s|45.7042

  • 百分比为对应的首映数目除以总titles数目,titles算入premieredNULL的条目,结果舍入到小数点后四位
1
2
3
4
5
6
7
8
SELECT
CAST(premiered/10*10 AS TEXT) || 's' AS decade,
ROUND(CAST(COUNT(*) AS REAL) / (SELECT COUNT(*) FROM titles) * 100.0, 4) as percentage
FROM titles
WHERE premiered is not null
GROUP BY decade
ORDER BY percentage DESC, decade ASC
;

查询结果如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2010s|45.7891
2000s|21.5555
1990s|9.2148
1980s|5.1971
1970s|4.3451
1960s|3.2787
1950s|1.7237
1910s|1.159
1920s|0.5732
1930s|0.5008
1940s|0.4363
1900s|0.4177
2020s|0.1086
1890s|0.0996
1880s|0.001
1870s|0.0

q6

列出转播次数的titles前十

  • 输出primary title和对应的数目

和q2类似,可通过with子句定义临时关系,LIMIT 10限定输出条目的数目再通过join运算限定title条目。

1
2
3
4
5
6
7
8
9
10
11
12
13
WITH translations AS (
SELECT title_id, count(*) as num_translations
FROM akas
GROUP BY title_id
ORDER BY num_translations DESC, title_id
LIMIT 10
)
SELECT titles.primary_title, translations.num_translations
FROM translations
JOIN titles
ON titles.title_id == translations.title_id
ORDER BY translations.num_translations DESC
;

查询结果如下

1
2
3
4
5
6
7
8
9
10
Mutant Virus: Vol. 1|126
The Good, the Bad and the Ugly|73
Star Wars: Episode V - The Empire Strikes Back|71
Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb|68
Raiders of the Lost Ark|62
Star Wars: Episode VII - The Force Awakens|62
The Shawshank Redemption|61
Once Upon a Time in the West|60
Indiana Jones and the Kingdom of the Crystal Skull|60
Airplane!|59

q7

列出IMDB中电影权重最高的250个

权重的计算方式为

1
Weighted rating (WR) = (v/(v+m)) * R + (m/(v+m)) * C
  • R为电影平均评分
  • v为评分人数
  • m为25000
  • C为所有电影的平均权重

weight的计算放入select语句中。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
WITH
av(average_rating) AS (
SELECT SUM(rating * votes) / SUM(votes)
FROM ratings
JOIN titles
ON titles.title_id == ratings.title_id AND titles.type == "movie"
),
mn(min_rating) AS (SELECT 25000.0)
SELECT
primary_title,
(votes / (votes + min_rating)) * rating + (min_rating / (votes + min_rating)) * average_rating as weighed_rating
FROM ratings, av, mn
JOIN titles
ON titles.title_id == ratings.title_id and titles.type == "movie"
ORDER BY weighed_rating DESC
LIMIT 250
;

榜单如下

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
The Shawshank Redemption|9.27408375213064
Pulp Fiction|8.87296068706845
The Lord of the Rings: The Return of the King|8.87023538818413
Schindler's List|8.85944837786486
12 Angry Men|8.8274654312365
Forrest Gump|8.77394665505175
The Good, the Bad and the Ugly|8.73410047935658
The Matrix|8.67379043068514
The Lord of the Rings: The Two Towers|8.67073273467584
Star Wars: Episode V - The Empire Strikes Back|8.66258036565461
Goodfellas|8.65679704067696
One Flew Over the Cuckoo's Nest|8.65294416076491
The Mountain II|8.61725087838868
City of God|8.54342805417796
Gladiator|8.47143742708625
Back to the Future|8.46332853886572
Léon: The Professional|8.46292056565729
Avengers: Infinity War|8.4506845289751
Psycho|8.4373696976068
Rear Window|8.41674755149826
Once Upon a Time in the West|8.38089735258473
WALL·E|8.36472733136252
Raiders of the Lost Ark|8.36071764723241
The Shining|8.35937143360229
Alien|8.35552530090484
Cinema Paradiso|8.3444698366033
Apocalypse Now|8.34271721766924
Grave of the Fireflies|8.34191265540178
Oldboy|8.33209348956415
Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb|8.3250687044724
Once Upon a Time in America|8.29149205920628
Spider-Man: Into the Spider-Verse|8.27944770565499
Inglourious Basterds|8.27361869242351
American Beauty|8.26993451202779
Reservoir Dogs|8.26439627161116
Requiem for a Dream|8.25798876833464
A Clockwork Orange|8.25742341547537
Toy Story 3|8.25734107724815
Scarface|8.25590438979589
Full Metal Jacket|8.25210853826772
Sunset Blvd.|8.23933898857354
Amadeus|8.21589004599775
Vertigo|8.21216347202948
Like Stars on Earth|8.20481373841464
Your Name.|8.19983566375586
North by Northwest|8.1975172347387
Batman Begins|8.17704665931913
V for Vendetta|8.17129916924205
Die Hard|8.16240649720068
Lock, Stock and Two Smoking Barrels|8.14585507926427
Casino|8.13629764272654
Unforgiven|8.12365074764615
The Apartment|8.12061011853697
Chinatown|8.10376481333931
My Neighbor Totoro|8.09442185609386
Green Book|8.09074160238658
Finding Nemo|8.07145216202776
Catch Me If You Can|8.06592479759894
The Grand Budapest Hotel|8.06129693202741
Blade Runner|8.06098971608469
Fargo|8.05647629910042
Prisoners|8.05390469414222
The Kid|8.05287532584739
Rush|8.03898582269203
Hacksaw Ridge|8.03551702468201
The Seventh Seal|8.03407390030423
The Princess Bride|8.03359206319394
Platoon|8.03211473247254
PK|8.02907703728921
Monty Python's Life of Brian|8.02901738104703
Gone with the Wind|8.01162552164356
Before Sunrise|8.00325016258364
Ben-Hur|7.98708858673506
The Elephant Man|7.98656566725627
The Treasure of the Sierra Madre|7.98183759819495
Aynabaji|7.97740941967294
Yojimbo|7.97326922828868
Star Wars: Episode VII - The Force Awakens|7.97147281541043
Slumdog Millionaire|7.97003387503103
Monsters, Inc.|7.96993549888079
Sin City|7.96864677307258
X-Men: Days of Future Past|7.96426564397762
Ratatouille|7.96198738026476
Jaws|7.95693515580935
Her|7.95337602084149
Cool Hand Luke|7.95284437581594
Akira|7.9466594640111
In the Name of the Father|7.94653731881204
Big Fish|7.94417520197508
Zootopia|7.94391037425039
Barry Lyndon|7.93804803727936
La Haine|7.93713874007203
Network|7.93673499353362
Ikiru|7.93587006088359
Harakiri|7.93442534185635
On the Waterfront|7.93384958766431
Drishyam|7.9316664137302
The Chaos Class Failed the Class|7.92209636316521
Magnolia|7.92151783450757
Swades|7.91791802696218
Children of Heaven|7.91488724265187
Tosun Pasa|7.91175384887872
Dog Day Afternoon|7.90497209143548
Before Sunset|7.90135907545106
Memories of Murder|7.89983909706083
Ip Man|7.89530989242938
Chak de! India|7.89380214739519
Munna Bhai M.B.B.S.|7.88766873353758
The 400 Blows|7.88236058087742
Elite Squad|7.88128931930257
Cinderella Man|7.87893854172733
Judgment at Nuremberg|7.87703872647609
Ayla: The Daughter of War|7.87111640888977
Toy Story 4|7.86727079414856
District 9|7.86716566170036
Edge of Tomorrow|7.86401183134919
Searching for Sugar Man|7.86361014282595
Thor: Ragnarok|7.86067171002219
Harry Potter and the Prisoner of Azkaban|7.86009831177006
The Handmaiden|7.86005695016839
Toy Story 2|7.85903363434152
The Bourne Identity|7.85871357953152
Three Colors: Red|7.8571771641382
Edward Scissorhands|7.85308436175456
Nightcrawler|7.85238182329928
Castle in the Sky|7.8494569785608
Paris, Texas|7.84540229570821
The Breakfast Club|7.84009539226878
Ghost in the Shell|7.8358170251987
Mulholland Dr.|7.83476463500115
Strangers on a Train|7.8340265331899
Papillon|7.83230035374453
The Raid 2|7.82177754544252
The Artist|7.81451845636192
The Man Who Shot Liberty Valance|7.8078751132418
True Romance|7.80358074659557
All the President's Men|7.80348137201329
A Streetcar Named Desire|7.80156298305092
My Name Is Khan|7.80054788180083
Patton|7.79504441225479
Tokyo Story|7.79422849952735
The Blues Brothers|7.79298260954459
The Man from Earth|7.78857212574483
Capernaum|7.78563829871188
Spider-Man: Far from Home|7.78561846386015
Vikram Vedha|7.78373473224346
Titanic|7.78157715805354
The Hobbit: An Unexpected Journey|7.77554863836764
The Passion of Joan of Arc|7.77408091487195
High and Low|7.77213704112255
Sing Street|7.76915812623775
The Legend of 1900|7.76815835496063
Elite Squad: The Enemy Within|7.76812044894699
Fanny and Alexander|7.76800472456941
Taken|7.76769012246336
The Straight Story|7.76752395340217
Kahaani|7.76720011579587
Ocean's Eleven|7.76364685071376
The Sea Inside|7.76289022497323
O.J.: Made in America|7.76250676256312
Before Midnight|7.76132220796731
Home|7.76025351500213
Back to the Future Part II|7.76009005121133
Spring, Summer, Fall, Winter... and Spring|7.7592446422894
Manhattan|7.7591232226754
Crash|7.757187612945
The Girl with the Dragon Tattoo|7.75600754037541
Big Hero 6|7.7544767707715
Predator|7.75096576853116
Spartacus|7.75079774492003
Isle of Dogs|7.7494869658895
The Fighter|7.74677127042658
The Game|7.7466716184388
The Big Short|7.7461656518056
Moonrise Kingdom|7.74269388072724
Pather Panchali|7.74145616936336
Doctor Zhivago|7.74112370242397
Apocalypto|7.73848649857271
About Time|7.7377698449424
Gattaca|7.73647859452984
What Ever Happened to Baby Jane?|7.73539364991903
The Marathon Family|7.73428987458458
Crouching Tiger, Hidden Dragon|7.73132118708057
Sunrise|7.72522570382843
Manchester by the Sea|7.72481321224648
La Dolce Vita|7.72473610906825
Halloween|7.72149520973176
Sherlock Jr.|7.72122901074544
What's Eating Gilbert Grape|7.71837046863796
Diabolique|7.71738924368521
Remember the Titans|7.7131373150204
Amour|7.71206424086562
Earthlings|7.71112168098164
Hidden Figures|7.70836846509536
The Boy in the Striped Pajamas|7.70750686722645
Throne of Blood|7.70486190012118
Nosferatu|7.70479615314119
The Best Years of Our Lives|7.70404091573498
La Strada|7.7035894202021
Blue Velvet|7.70348849922288
Ed Wood|7.70011913851453
Carry On, Munna Bhai|7.6960703370653
The Insider|7.69589363902872
Rio Bravo|7.69547902962826
Do the Right Thing|7.69470637286005
G.O.R.A.|7.69143691201405
John Wick: Chapter 3 - Parabellum|7.69042140474976
The Big Sleep|7.69022732193082
The Best of Youth|7.68939089676166
The Wild Bunch|7.68732321899666
Evil Dead II|7.68698809399903
Airlift|7.68482585880285
Who's Singin' Over There?|7.68275319170322
The King of the Street Cleaners|7.68007124396815
Blue Is the Warmest Color|7.67888277323536
300|7.67811080177943
The Hangover|7.67745136243525
The Chaos Class Is on Vacation|7.67701815540533
Kramer vs. Kramer|7.6734998783239
Special 26|7.67149062884843
Harold and Maude|7.67125075421178
Breathless|7.66994880180493
3-Iron|7.66894856428393
Glory|7.66830445780438
Awakenings|7.66753775055519
Star Trek Into Darkness|7.66655348768595
To Be or Not to Be|7.66618772896992
A Silent Voice|7.66616985054611
Get Out|7.66418042868228
The Fifth Element|7.66340814153364
Zodiac|7.66276470401316
Empire of the Sun|7.66123857830932
Lost in Translation|7.66075124608843
Man with a Movie Camera|7.66048361595785
Tangled|7.66012044434097
Once|7.65980150013791
Midnight in Paris|7.65893069763627
The King of Kong: A Fistful of Quarters|7.65818054427474
Wreck-It Ralph|7.6578968805438
The Salt of the Earth|7.6573311856226
The Fault in Our Stars|7.65410038215701
Time of the Gypsies|7.65354312829129
Lucky Number Slevin|7.64972806598217
Whisper of the Heart|7.64876091986559
O Brother, Where Art Thou?|7.64584931637816
Talvar|7.64560053612369
Donnie Brasco|7.6439766475949
As Good as It Gets|7.64393017265743
The Motorcycle Diaries|7.64367118785382
The Girl with the Red Scarf|7.64023075719264

榜单第一是肖申克的救赎,惊了!

q8

列出和Mark Hamill合作过的男演员/女演员的数量

  • 仅输出数量
1
2
3
4
5
6
7
8
9
10
WITH hamill_titles AS (
SELECT DISTINCT(crew.title_id)
FROM people
JOIN crew
ON crew.person_id == people.person_id AND people.name == "Mark Hamill" AND people.born == 1951
)
SELECT COUNT(DISTINCT(crew.person_id))
FROM crew
WHERE (crew.category == "actor" OR crew.category == "actress") AND crew.title_id in hamill_titles
;

查询结果为206

q9

按照字典序列出Mark Hamill(生于1951年)和George Lucas(生于1944年)共同参演的作品

1
2
3
4
5
6
7
8
9
10
11
12
13
14
WITH hamill_movies(title_id) AS (
SELECT crew.title_id
FROM crew
JOIN people
ON crew.person_id == people.person_id AND people.name == "Mark Hamill" AND people.born == 1951
)
SELECT titles.primary_title
FROM crew
JOIN people
ON crew.person_id == people.person_id AND people.name == "George Lucas" AND people.born == 1944 AND crew.title_id IN hamill_movies
JOIN titles
ON crew.title_id == titles.title_id AND titles.type == "movie"
ORDER BY titles.primary_title
;

查询结果为

1
Star Wars: Episode V - The Empire Strikes Back

仅有一部电影

q10

列出所有不同的标签和相关的titles数目

不同标签之间以逗号间隔,所以需要从genre中提取出对应的标签信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
WITH RECURSIVE split(genre, rest) AS (
SELECT '', genres || ',' FROM titles WHERE genres != "\N"
UNION ALL
SELECT substr(rest, 0, instr(rest, ',')),
substr(rest, instr(rest, ',')+1)
FROM split
WHERE rest != ''
)
SELECT genre, count(*) as genre_count
FROM split
WHERE genre != ''
GROUP BY genre
ORDER BY genre_count DESC;

查询结果为

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
Drama|620063
Comedy|486163
Short|310619
Documentary|222187
Talk-Show|215144
Romance|211462
Family|159035
News|148941
Animation|115998
Reality-TV|113180
Music|105724
Crime|99019
Action|97544
Adventure|81686
Game-Show|75169
Adult|65704
Sport|48855
Fantasy|48341
Mystery|47155
Horror|41552
Thriller|40664
History|31675
Sci-Fi|31441
Biography|27001
Musical|17939
Western|9811
War|9309
Film-Noir|322