决定是否与Parse.com使用一对多,多对多或一对一关系以用于iOS照片共享应用程序 [英] Deciding whether to use a one-to-many, many-to-many, or one-to-one relationship with Parse.com for iOS photo sharing app

查看:66
本文介绍了决定是否与Parse.com使用一对多,多对多或一对一关系以用于iOS照片共享应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Parse.com为iPhone创建照片共享应用程序,到目前为止,一切都非常容易,我刚刚完成了编写将照片上传到Parse服务器的代码.

I am creating a photo sharing app for the iPhone using Parse.com and so far everything has been pretty easy and I just finished writing the code for uploading photos to the Parse server.

到目前为止,我一直在使用默认的"_User"类.以下是为每个用户存储的一些关键数据类型:objectId,用户名,电子邮件和一个名为"friends"的数组对象,该对象包含用户已添加到其朋友列表中的数据库中其他用户的用户名.

So far, I have been using the default "_User" class. Here are some of the key types of data that are being stored for each user: objectId, username, email, and an array object called "friends" that contains the usernames of other users in the database that the user has added to their friends list.

现在,我需要设置用户之间的实际共享功能.我一直在阅读Parse文档,我需要决定是使用一对多,多对多还是一对一的关系.然后,根据最终选择的对象,我将需要决定是使用指针,数组,解析关系还是联接表.

Now, I need to setup the actual sharing functionality between users. I have been going through the Parse documentation and I need to decide whether to use a one-to-many, many-to-many, or one-to-one relationship. Depending on which one I end up choosing, I then will need to decide between using pointers, arrays, parse relations, or join tables.

我将快速解释我要实现的共享"功能:

I am going to quickly explain the "sharing" functionality that I am trying to achieve:

  1. 对于我的照片应用程序,user1通过拍照并选择将其发送给名为user2的朋友列表中的朋友来启动关系".

  1. For my photo app, user1 starts the "relationship" by taking a photo and choosing to send it to a friend on their friends list named user2 .

然后将照片上传到Parse并发送给user2.

The photo is then uploaded to Parse and sent to user2.

user2从user1接收照片.

user2 receives the photo from user1.

user2打开照片,使用应用程序的编辑工具并在原始照片上随机绘制一些东西来完成"关系"是他们的工作.例如:user2在照片中user1的脸旁边绘制一个心形.

user2 opens the photo and it is their job to "finish" the "relationship" by using the app's editing tools and drawing something random on the original photo. Example: user2 draws a heart next to user1's face in the photo.

当user2完成后,最终照片将保存到他们的个人资料中,并发送回原始发件人user1,关系"现在完成并完成/关闭.

When user2 is finished, the final photo is saved to their profile and also sent back to the original sender, user1, and the "relationship" is now finished and completed/closed.

在阅读了文档并进行了自己的研究之后,我得出的结论是,我需要使用联接表"使用多对多"关系,以便可以包含元数据.

After reading through the docs and doing my own research, I have come to the conclusion that I need to use a Many-To-Many relationship using Join Tables so that I can include metadata.

但是,我通常对Objective-C和编程不熟悉,如果我有可能选择了错误的解决方案或不必要的解决方案,而在开始之前没有要求输入意见和建议,那我就懒了

However, I am new to objective-c and programming in general and it would be lazy of me if I did not ask for input and advice before getting started when it is possible that I have chosen the wrong solution or an unnecessary solution.

推荐答案

您的问题更多是关于数据库管理,而不是与Obj-C有关的事情.

Your question is more about your DB management than anything to do with Obj-C.

考虑在您的数据库中使用名为SharedImage的新类,该类承载图像,指向始发者和接收者的链接(1到1,因此我们可以使用指针或关系)以及任何其他数据您需要.

Think about using a new class in your DB called SharedImage which hosts the image(s), a link to the originator and the recipient (1 to 1, so could us a pointer or a relationship) and any other data you need.

现在您可以根据需要创建这些对象,并且可以基于查询使用当前用户来获取它们.

Now you can create these objects are you require and you can fetch them based on queries using the current user.

此外,对于您说的现有的friends数组,其中包含朋友的用户名-最好存储朋友的objectId而不是用户名(因为通常可以更改用户名,但objectId是静态的.

Also, for your existing friends array which you said holds the usernames of the friends - it would probably be better to store the objectIds of the friends instead of the usernames (because the username can usually be changed, but the objectId is static).

这篇关于决定是否与Parse.com使用一对多,多对多或一对一关系以用于iOS照片共享应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆