|
4 | 4 | "cell_type": "markdown", |
5 | 5 | "metadata": {}, |
6 | 6 | "source": [ |
7 | | - "# Languages Database Example\n", |
| 7 | + "# Example: Languages \n", |
8 | 8 | "\n", |
9 | 9 | "This example demonstrates a classic many-to-many relationship design using an association table. We'll track people and the languages they speak, along with their fluency levels.\n", |
10 | 10 | "\n", |
|
719 | 719 | }, |
720 | 720 | { |
721 | 721 | "cell_type": "code", |
722 | | - "execution_count": 8, |
| 722 | + "execution_count": null, |
723 | 723 | "metadata": {}, |
724 | 724 | "outputs": [ |
725 | 725 | { |
|
818 | 818 | }, |
819 | 819 | { |
820 | 820 | "cell_type": "code", |
821 | | - "execution_count": 9, |
| 821 | + "execution_count": null, |
822 | 822 | "metadata": {}, |
823 | 823 | "outputs": [ |
824 | 824 | { |
|
924 | 924 | ], |
925 | 925 | "source": [ |
926 | 926 | "# Query 4: Show the peole who speak at least four languages\n", |
927 | | - "Person.aggr(Fluency, 'name', nlanguages='count(lang_code)', languages='GROUP_CONCAT(lang_code)') & 'nlanguages >= 4'" |
| 927 | + "Person.aggr(Fluency, 'name',\n", |
| 928 | + " nlanguages='count(lang_code)', languages='GROUP_CONCAT(lang_code)'\n", |
| 929 | + " ) & 'nlanguages >= 4'" |
928 | 930 | ] |
929 | 931 | }, |
930 | 932 | { |
931 | 933 | "cell_type": "code", |
932 | | - "execution_count": 10, |
| 934 | + "execution_count": null, |
933 | 935 | "metadata": {}, |
934 | 936 | "outputs": [ |
935 | 937 | { |
|
1028 | 1030 | ], |
1029 | 1031 | "source": [ |
1030 | 1032 | "# Query 5: Show the top 3 people by number of languages spoken\n", |
1031 | | - "Person.aggr(Fluency, 'name', nlanguages='count(lang_code)') & dj.Top(3, order_by='nlanguages desc')" |
| 1033 | + "Person.aggr(Fluency, 'name',\n", |
| 1034 | + " nlanguages='count(lang_code)'\n", |
| 1035 | + " ) & dj.Top(3, order_by='nlanguages desc')" |
1032 | 1036 | ] |
1033 | 1037 | }, |
1034 | 1038 | { |
1035 | 1039 | "cell_type": "code", |
1036 | | - "execution_count": 11, |
| 1040 | + "execution_count": null, |
1037 | 1041 | "metadata": {}, |
1038 | 1042 | "outputs": [ |
1039 | 1043 | { |
|
1134 | 1138 | "source": [ |
1135 | 1139 | "# Query 6: Show all the people Lindsay Roman (person_id=7) can communicate wtih\n", |
1136 | 1140 | "\n", |
1137 | | - "Person & (Fluency * Fluency.proj(other_person='person_id') & {'other_person': 7})\n" |
| 1141 | + "Person & (\n", |
| 1142 | + " Fluency * Fluency.proj(other_person='person_id') & {'other_person': 7}\n", |
| 1143 | + " )\n" |
1138 | 1144 | ] |
1139 | 1145 | }, |
1140 | 1146 | { |
|
0 commit comments