-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11. Core Data Demo.srt
7959 lines (6368 loc) · 179 KB
/
11. Core Data Demo.srt
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
1
00:00:00,401 --> 00:00:04,569
[MUSIC]
(音乐)
2
00:00:04,638 --> 00:00:08,339
Stanford University,
斯坦福大学,
3
00:00:08,408 --> 00:00:11,075
>> Welcome to Stanford CS193P,
> >欢迎来到斯坦福CS193P,
4
00:00:11,144 --> 00:00:13,978
developing applications for iOS,
iOS应用程序开发,
5
00:00:14,047 --> 00:00:16,414
It's winter of 2017,
这是2017年冬天,
6
00:00:16,483 --> 00:00:19,083
This is lecture number 11 and
这是11号和讲座
7
00:00:19,152 --> 00:00:22,654
today we're gonna do one gigantic demo,
今天我们要做一个巨大的演示,
8
00:00:22,723 --> 00:00:25,390
Last time I made you suffer through basically doing
上次我让你遭受基本上做的
9
00:00:25,459 --> 00:00:26,625
all slides,
所有幻灯片,
10
00:00:26,693 --> 00:00:30,895
Now, you get to enjoy all demo for the whole time,
现在,你可以享受所有演示了整个时间,
11
00:00:30,964 --> 00:00:33,464
And it's all gonna be about Core Data and applying all
都是会对核心数据和应用
12
00:00:33,533 --> 00:00:36,268
the things that we learned in the last lecture into a demo,
我们在上节课学到的演示,
13
00:00:36,337 --> 00:00:38,870
And then we'll be coming back to the slides, so
然后我们会回到幻灯片,
14
00:00:38,938 --> 00:00:42,374
let me just give you a heads up of what's happening here,
让我给你一个头这里发生了什么,
15
00:00:42,443 --> 00:00:45,043
On Friday, we have this other database mechanism for
上周五,我们有这个其他数据库的机制
16
00:00:45,112 --> 00:00:46,712
storing data in iCloud,
在云存储数据,
17
00:00:46,780 --> 00:00:50,248
I highly recommen this one, at our Friday section,
我强烈recommen这个,在我们周五部分,
18
00:00:50,316 --> 00:00:51,883
normal place and time,
正常的地点和时间,
19
00:00:51,951 --> 00:00:52,918
Monday's a holiday, so
周一的一个节日,所以
20
00:00:52,986 --> 00:00:55,353
don't show up here on Monday cuz I won't be here,
周一没有出现在这里因为我不会在这里,
21
00:00:55,422 --> 00:00:58,356
And then next Wednesday, I'll be going over the final
然后下个星期三,我将会在最后
22
00:00:58,425 --> 00:01:01,226
project requirements, including the rubric, and
项目需求,包括标题和
23
00:01:01,295 --> 00:01:03,795
also we'll be doing the topic, autolayout,
我们也会做主题,自动布局,
24
00:01:03,863 --> 00:01:09,200
Now, your assignment five has been
现在,作业5
25
00:01:09,269 --> 00:01:14,439
posted already, and it's due one
已经发布了,它是由于一个
26
00:01:14,508 --> 00:01:19,544
week from today before lecture,
星期从今天开始演讲之前,
27
00:01:19,612 --> 00:01:23,882
So here's Smashtag from last week,
这是Smashtag从上周,
28
00:01:23,950 --> 00:01:26,952
Remember we have this one MVC where we type in a search
记得我们有这一个MVC输入一个搜索
29
00:01:27,020 --> 00:01:29,354
string, #Stanford or whatever else,
字符串,#斯坦福或者其他,
30
00:01:29,423 --> 00:01:31,790
and it pulls down a bunch of tweets,
这一群推拉下,
31
00:01:31,859 --> 00:01:34,592
Now we're just gonna add another MVC,
现在,我们要添加另一个MVC,
32
00:01:34,661 --> 00:01:35,961
a core data driven MVC,
一个核心数据驱动的MVC,
33
00:01:36,029 --> 00:01:40,198
And when this MVC is gonna show all the Twitter users who
当这个MVC会显示所有的Twitter用户
34
00:01:40,267 --> 00:01:44,035
tweeted all the tweets that are showing in this MVC
在推特上的所有微博显示MVC
35
00:01:44,104 --> 00:01:45,069
right here,
在这里,
36
00:01:45,138 --> 00:01:48,072
So, if you type a certain search term like #Stanford,
所以,如果你输入一个特定的搜索词像#斯坦福大学,
37
00:01:48,141 --> 00:01:49,674
Stanford gets a bunch of tweets,
斯坦福大学被一群微博,
38
00:01:49,743 --> 00:01:51,342
And then there's gonna be a button on this MVC,
然后会有一个按钮在这个MVC,
39
00:01:51,411 --> 00:01:52,878
we're gonna put it up in the title bar,
我们要把它的标题栏,
40
00:01:52,946 --> 00:01:54,780
we're gonna show you how to do that as well,
我们会告诉你怎么做,
41
00:01:54,848 --> 00:01:55,881
And you're gonna click that button,
你会点击那个按钮,
42
00:01:55,949 --> 00:01:58,483
It's gonna bring a new MVC with all the users, and
它会带来一个新的MVC的用户,和
43
00:01:58,552 --> 00:02:00,552
we'll also put in there how many times,
我们也会把多少次,
44
00:02:00,621 --> 00:02:02,187
how many tweets they tweeted,
多少微博发微博
45
00:02:02,256 --> 00:02:05,990
When we do that, we're only gonna be looking at the tweets
当我们这样做,我们只会看微博
46
00:02:06,059 --> 00:02:08,593
that are in this result, this search result right here,
在这个结果,这个搜索结果,
47
00:02:08,662 --> 00:02:11,329
or that have ever come from typing this search term,
或者曾经来自输入搜索词,
48
00:02:11,398 --> 00:02:15,233
All right, so this is all gonna be core data,
好吧,这是所有核心数据,
49
00:02:15,302 --> 00:02:17,469
So we need core data in our app,
所以我们需要核心数据在我们的应用程序,
50
00:02:17,537 --> 00:02:20,805
When we built Smashtag we didn't click use core data, so
当我们建立Smashtag没有点击使用核心数据,
51
00:02:20,874 --> 00:02:23,708
we're gonna have to go through the procedures that I talked
我们要办理的手续,我说
52
00:02:23,777 --> 00:02:28,514
about last time for adding core data to our app,
关于上次的核心数据添加到我们的应用程序,
53
00:02:28,582 --> 00:02:30,916
And we're gonna do that by creating a dummy
我们要做的,通过创建一个假
54
00:02:30,984 --> 00:02:31,749
app right here,
应用程序在这里,
55
00:02:31,818 --> 00:02:33,885
Let's go to New > Project,
让我们去新的>项目时,
56
00:02:33,954 --> 00:02:35,454
So we're gonna create a dummy project,
所以我们要创建一个虚拟项目,
57
00:02:35,522 --> 00:02:37,189
you can call this project anything you want,
这个项目你可以叫任何你想要的,
58
00:02:37,257 --> 00:02:39,057
I'm gonna call it Foo,
我要叫它Foo,
59
00:02:39,125 --> 00:02:42,528
Just make sure that Use Core Data is clicked right there,
确保使用核心数据点击,
60
00:02:44,130 --> 00:02:46,397
We can put it anywhere we want cuz we're just gonna turn
我们可以在任何地方把它因为我们要
61
00:02:46,466 --> 00:02:47,866
around and delete it in a moment,
删除它,
62
00:02:47,934 --> 00:02:50,702
And you can see that it has created this dummy project,
你可以看到它已经创造了这个虚拟项目,
63
00:02:50,771 --> 00:02:52,738
And all we're really interested in here is
和所有我们真正感兴趣的
64
00:02:52,806 --> 00:02:55,507
the code from the AppDelegate that does core data,
的代码在AppDelegate核心数据,
65
00:02:55,576 --> 00:02:58,610
You can see that this AppDelegate imports CoreData,
你可以看到这个AppDelegate CoreData进口,
66
00:02:58,679 --> 00:03:01,345
Now we haven't talked about the AppDelegate, and we will,
现在我们还没有谈到在AppDelegate,我们将
67
00:03:01,414 --> 00:03:04,115
It's part of the application lifecycle,
这是应用程序生命周期的一部分,
68
00:03:04,184 --> 00:03:05,016
But, for now,
但是,就目前而言,
69
00:03:05,084 --> 00:03:07,452
all we need to know is that we're gonna go down here and
我们需要知道的是,我们要在这里
70
00:03:07,521 --> 00:03:08,754
get this stuff or core data,
得到这个东西或核心数据,
71
00:03:08,822 --> 00:03:12,157
you recognize this from the slides,
你认识这个幻灯片,
72
00:03:12,225 --> 00:03:16,094
And notice also this applicationWillTerminate calls
注意这个applicationWillTerminate调用
73
00:03:16,163 --> 00:03:17,295
saveContext,
saveContext,
74
00:03:17,364 --> 00:03:21,366
SaveContext is one of the Core Data methods that you get for
SaveContext是核心数据的方法得到
75
00:03:21,434 --> 00:03:23,051
So I'm actually gonna select that as well as all the rest
所以我要选择,以及所有的休息
76
00:03:23,052 --> 00:03:24,669
free here,
在这里,自由
77
00:03:24,738 --> 00:03:27,906
of this stuff is marked Core Data right there,
这些被标记的核心数据,
78
00:03:27,975 --> 00:03:29,307
And I'm just gonna copy it,
我要复制它,
79
00:03:29,376 --> 00:03:31,776
I'm gonna close this project cuz I don't need it,
我要关闭这个项目因为我不需要它,
80
00:03:31,845 --> 00:03:35,547
And I'm gonna go over to the AppDelegate in my Smashtag
我要去在AppDelegate Smashtag
81
00:03:35,616 --> 00:03:36,447
right here,
在这里,
82
00:03:36,516 --> 00:03:39,017
And you can see it doesn't import core data right there
你可以看到它不导入核心数据
83
00:03:39,086 --> 00:03:39,584
at the top,
在顶部,
84
00:03:39,653 --> 00:03:41,919
Nor does applicationWillTerminate call
applicationWillTerminate也不叫
85
00:03:41,988 --> 00:03:45,390
SaveContext, nor does it have any of other stuff down there,
SaveContext,也没有任何其他的东西,
86
00:03:45,459 --> 00:03:48,393
So I'm just gonna take that code and paste in here,
所以我要把代码粘贴在这里,
87
00:03:48,461 --> 00:03:53,197
And this code is generic, it works in all applications,
这代码是通用的,适用于所有应用程序,
88
00:03:53,266 --> 00:03:56,768
The only thing that's specific about it is this string right
唯一的具体这个字符串是正确的
89
00:03:56,837 --> 00:03:59,938
here, which tells you the data model, the thing that
,告诉你数据模型,的事情
90
00:04:00,007 --> 00:04:03,575
describes the schema of your object or in a database,
描述了对象的模式或数据库中,
91
00:04:03,643 --> 00:04:06,044
Now you notice we have an error right here, that's
现在你注意到我们有一个错误,这是
92
00:04:06,112 --> 00:04:08,780
because it doesn't recognize NSPeristentContainer,
因为它不认识NSPeristentContainer,
93
00:04:08,848 --> 00:04:12,784
Because NSPeristentContainer is in a different framework
因为NSPeristentContainer是在一个不同的框架
94
00:04:12,853 --> 00:04:15,019
than UIKit, it's in CoreData,
比UIKit CoreData,
95
00:04:15,088 --> 00:04:18,657
So every time you're using CoreData in a swift file,
所以每次你使用CoreData在迅速文件中,
96
00:04:18,725 --> 00:04:22,494
you need to import CoreData or it won't recognize in this
你需要进口CoreData也不会承认这一点
97
00:04:22,563 --> 00:04:27,466
managed object or any of the other symbols from core data,
管理对象或任何其他符号的核心数据,
98
00:04:27,534 --> 00:04:31,303
So that's one thing we have to do that we use Core Data
这是我们必须做的一件事,我们使用核心数据
99
00:04:31,371 --> 00:04:33,004
The other one is actually create the data model itself,
另一个是实际创建数据模型本身,
100
00:04:33,005 --> 00:04:34,638
button did,
按钮,
101
00:04:34,708 --> 00:04:36,641
And that we do with File > New > File, so
我们与File > New >文件,
102
00:04:36,710 --> 00:04:38,276
I'm gonna go File > New > File,
点击File > New >文件,
103
00:04:38,345 --> 00:04:42,080
And we, normally we're picking things up here but we're gonna
我们通常我们捡东西但我们会
104
00:04:42,149 --> 00:04:46,651
scroll down to where it says Core Data and pick Data Model,
向下滚动到核心数据和数据模型,
105
00:04:46,720 --> 00:04:48,787
We don't want Mapping Model, we want Data Model,
我们不想映射模型,数据模型,
106
00:04:50,257 --> 00:04:52,324
This is just gonna be that thing where we describe all
这只是将那件事我们描述所有的地方
107
00:04:52,393 --> 00:04:55,026
our entities and attributes,
我们的实体和属性,
108
00:04:55,095 --> 00:04:56,528
And we can call it anything we want,
我们可以叫它任何我们想要的,
109
00:04:56,597 --> 00:04:59,330
Just to be kind of different I'm gonna call it Smash,
只是有点不同的我要叫它打碎,
110
00:04:59,399 --> 00:05:02,567
That's gonna be the name of my Data Model,
这是要我的名字数据模型,
111
00:05:02,636 --> 00:05:03,935
And I'm not gonna put in Supporting Files,
和我不会放在支持文件,
112
00:05:04,004 --> 00:05:07,305
I'm gonna put it in Smashtag in a higher,
我要把它放在Smashtag更高,
113
00:05:07,374 --> 00:05:10,308
this level up here and click Create,
这个水平并单击创建、
114
00:05:10,376 --> 00:05:10,908
And here it is,
是这样的,
115
00:05:10,977 --> 00:05:12,277
You can probably recognize this, right?
你可以认识到这一点,对吧?
116
00:05:12,346 --> 00:05:13,311
This is our entities and attributes,
这是我们的实体和属性,
117
00:05:13,380 --> 00:05:15,046
We haven't put any of them in there,
我们还没有把其中的任何一个,
118
00:05:15,115 --> 00:05:18,583
Now, since I call this Smash and not Foo,
现在,既然我称之为粉碎而不是Foo,
119
00:05:18,652 --> 00:05:21,719
I've to go back to my AppDelegate and
我回到AppDelegate和
120
00:05:21,788 --> 00:05:26,625
change this Foo string in here to be Smash,
改变这个字符串Foo被粉碎,
121
00:05:26,693 --> 00:05:29,494
So I've pretty much now reproduced everything that
所以我现在几乎复制一切
122
00:05:29,562 --> 00:05:31,263
the use core data button would do,
使用核心数据按钮,
123
00:05:31,331 --> 00:05:33,631
The only difference would be the use core data would have
唯一不同的是使用核心数据
124
00:05:33,700 --> 00:05:34,966
called my xcdatamodeld file,
叫我xcdatamodeld文件,
125
00:05:35,034 --> 00:05:36,868
It would have called it Smashtag,
它会称之为Smashtag,
126
00:05:36,937 --> 00:05:40,205
cuz that's the name of my app, but I like to call it Smash,
因为这是我的程序的名字,但是我喜欢叫它打碎,
127
00:05:41,674 --> 00:05:45,210
All right, so now that we have this nice data model file,
好了,现在我们有这个很好的数据模型文件,
128
00:05:45,279 --> 00:05:47,678
let's go ahead and create our schema,
让我们创建模式,
129
00:05:47,747 --> 00:05:51,383
Now, I'm gonna do this really quick because I already showed
现在,我要做这个很快,因为我已经显示
130
00:05:51,451 --> 00:05:54,151
you how to do all this which you can just watch it
你如何做这一切,你可以看它
131
00:05:54,220 --> 00:05:55,487
happening real fast,
发生的很快,
132
00:05:55,555 --> 00:05:58,756
I'm not gonna show you anything that I didn't show
我不会告诉你任何我没有展示
133
00:05:58,825 --> 00:06:00,391
you in the last lecture,
你的最后一课,
134
00:06:00,460 --> 00:06:03,027
I'm gonna start by adding an entity down here at
下面我要开始通过添加一个实体
135
00:06:03,096 --> 00:06:04,980
All right, this entity I'm going to rename it,
好吧,这个实体我要重命名它,
136
00:06:04,981 --> 00:06:06,865
the bottom,
底部,
137
00:06:06,933 --> 00:06:10,368
And I'm gonna do tweets and Twitter users cuz I'm gonna
我要做微博和推特用户因为我要
138
00:06:10,437 --> 00:06:13,204
have that table that follows Twitter users,
那张桌子,Twitter用户,
139
00:06:13,273 --> 00:06:15,073
But obviously those Twitter users are determined by
但显然这些Twitter用户是由
140
00:06:15,142 --> 00:06:17,108
a bunch of tweets, so those are two entities I need,
一群微博,所以我需要这两个实体,
141
00:06:17,176 --> 00:06:19,945
So let's put Tweet here first, and
所以我们先把推特这里,
142
00:06:20,013 --> 00:06:21,446
we'll add attributes for the tweet,
我们将添加属性的微博,
143
00:06:21,515 --> 00:06:24,382
I'm gonna add them by clicking this little plus right here,
我要把它们通过点击这个小加在这里,
144
00:06:24,451 --> 00:06:28,953
So we have the Text Attribute which is a String,
我们是一个字符串的文本属性,
145
00:06:29,022 --> 00:06:33,157
We have our tweets, what if we search for
我们有微博,如果我们在搜寻什么
146
00:06:33,226 --> 00:06:34,792
#Stanford twice in a row?
#斯坦福连续两次吗?
147
00:06:34,861 --> 00:06:36,694
We might get the same tweet back,
我们可能会得到同样的推回来,
148
00:06:36,763 --> 00:06:38,763
And we want our database to have unique tweets,
我们希望我们的数据库有独特的微博,
149
00:06:38,832 --> 00:06:40,865
we don't wanna every time we search we're getting more and
我们不想每次我们搜索我们获得更多
150
00:06:40,934 --> 00:06:42,400
more of the same tweet in there,
更多相同的微博,
151
00:06:42,469 --> 00:06:44,702
So I need some sort of unique
所以我需要某种独一无二的
152
00:06:44,771 --> 00:06:47,472
attribute in my database which is gonna a string,
属性在我的数据库是一个字符串,
153
00:06:47,541 --> 00:06:51,743
Luckily, the Twitter info that comes in the Twitter
幸运的是,Twitter的Twitter信息
154
00:06:51,811 --> 00:06:53,911
framework, it has a unique identifier in there for
框架,它有一个惟一的标识符
155
00:06:53,980 --> 00:06:56,481
tweets so it'll be really easy to set that,
微博所以就很容易,
156
00:06:56,549 --> 00:06:57,982
And I'm not gonna use this but for
我不会使用这个但
157
00:06:58,051 --> 00:07:02,286
example, if I wanted a created attribute it would be a date,
例子,如果我想要一个创建属性,那将是一个日期,
158
00:07:02,355 --> 00:07:03,287
I would just click Date,
我就点击日期,
159
00:07:03,356 --> 00:07:06,490
I'm putting this in here cuz I just wanna show you what
我将在这里因为我想告诉你什么
160
00:07:06,559 --> 00:07:08,426
it's like to set a date in code,
就像在代码中设定一个日期,
161
00:07:08,495 --> 00:07:09,461
This looks slightly tricky,
这看起来有点棘手,
162
00:07:09,530 --> 00:07:10,528
So I'm gonna add another, or
所以我要添加另一个,或
163
00:07:10,597 --> 00:07:12,596
actually we could look here in the Editor Style,
实际上我们可以看这里的编辑风格,
164
00:07:12,665 --> 00:07:14,332
So this is the exact same thing here in
这是相同的东西在这里
165
00:07:14,401 --> 00:07:15,500
the Editor Style,
编辑风格,
166
00:07:15,569 --> 00:07:16,334
When you're in Editor Style,
当你在编辑风格,
167
00:07:16,403 --> 00:07:19,170
you're almost always gonna have your inspector
你几乎总是会有你的检查员
168
00:07:19,239 --> 00:07:22,140
open right here so that you can click on things and
打开这里,这样您就可以点击,
169
00:07:22,209 --> 00:07:24,742
change their types and things like that,
改变他们的类型和类似这样的事情,
170
00:07:24,811 --> 00:07:27,378
I'm gonna create another entity here and it's going to
我要创建另一个实体,它会
171
00:07:27,447 --> 00:07:30,215
be our Twitter user, I'm gonna call that Twitter user,
是我们的Twitter用户,我要调用Twitter用户,
172
00:07:33,253 --> 00:07:34,752
And notice when I move these around,
注意当我移动这些,
173
00:07:34,821 --> 00:07:37,422
it moves it around whatever other entities there are,
它在任何其他实体,
174
00:07:37,491 --> 00:07:39,357
And I'm gonna be connecting these two and
我要这两个和连接
175
00:07:39,425 --> 00:07:42,160
creating a relationship, and you're gonna see it's gonna
创建一个关系,你会看到它
176
00:07:42,228 --> 00:07:43,829
keep drawing it as we draw there,
保持它画成画,
177
00:07:44,864 --> 00:07:46,697
So let's add some attributes here,
让我们添加一些属性,
178
00:07:46,766 --> 00:07:48,200
So I'm gonna click Add Attribute,
所以我要点击添加属性,
179
00:07:50,804 --> 00:07:57,475
Sorry,
对不起,
180
00:07:57,544 --> 00:07:59,244
It's not deleting, let's go back to Editor Style here,
不是删除,让我们回到编辑风格,
181
00:08:04,751 --> 00:08:08,019
By the way, I do notice sometimes that when selecting
顺便说一下,我确实注意到有时,当选择
182
00:08:08,087 --> 00:08:12,356
things, it's not always that great,
事情,这并不总是很好,
183
00:08:12,425 --> 00:08:13,657
it doesn't do that great a job,
没有伟大的工作,
184
00:08:13,726 --> 00:08:15,927
I'm not sure what it is about the data modeler that makes it
我不确定这是什么使得它的数据建模师
185
00:08:15,996 --> 00:08:17,629
that way, but you'll click on something,
这样,但是你会点击,
186
00:08:17,697 --> 00:08:19,564
and it doesn't click on that thing,
也不会点击它,
187
00:08:19,633 --> 00:08:21,232
it clicked the entity or something else,
它点击实体或别的东西,
188
00:08:21,300 --> 00:08:23,268
So there is an example where I was clicking on that
这是一个例子,我是点击
189
00:08:23,336 --> 00:08:25,503
attribute, but it wouldn't let me delete it,
属性,但它不让我删除它,
190
00:08:25,572 --> 00:08:27,171
Here I have Twitter user chosen,
在这里我有推特用户选择,
191
00:08:27,240 --> 00:08:28,539
hopefully add attribute,
希望添加属性,
192
00:08:28,608 --> 00:08:30,741
Yes, it adds it to the Twitter user,
是的,它将其添加到Twitter用户,
193
00:08:30,810 --> 00:08:34,078
The only attributes I'm gonna have on my Twitter user
唯一我要对我的Twitter用户属性
194
00:08:34,147 --> 00:08:38,683
are the handle, that's your @whatever, and then your name,
处理,这是你的@whatever,然后你的名字,
195
00:08:40,153 --> 00:08:43,021
And those are both going to be strings, so
这些都是字符串,所以
196
00:08:43,089 --> 00:08:46,524
we'll go over here and make this be of type string,
我们去这里,这是string类型的,
197
00:08:46,593 --> 00:08:51,595
And we'll also make the handle be type string,
和我们也会使处理字符串类型,
198
00:08:51,664 --> 00:08:54,499
So that's it for the attributes,
这是它的属性,
199
00:08:54,567 --> 00:08:56,834
And the only thing we have left to do is the relationship
和我们唯一剩下要做的就是关系
200
00:08:56,903 --> 00:08:57,735
between these two,
在这两个之间,