If one looks at the Movie type in schema.org, both actor and actors properties are allowed (actor supersedes actors). But there is no equivalent for author and contributor properties. In my view, a News Article for example, can often can have multiple authors and/or contributors.
The orderedItem property in Order allows for a single OrderItem/Product, or a collection of OrderItems/Products. Can we do the same with the author and contributor properties, ie. save multiple entities in a collection?
You can add a property multiple times.
For example, a Movie could have two actors:
<article typeof="schema:Movie">
<ul>
<li property="schema:actor" typeof="schema:Person">…</li>
<li property="schema:actor" typeof="schema:Person">…</li>
</ul>
</article>
Or a Person could have two names.
Related
I am new to MongoDB moving in from traditional SQL relational approach. I am working on a simple “Category has many Products” scenario (c#.Net). Where Category has
List<Product>
My questions are.
Question 1: On Add Product screen I have a drop down for Categories. So on Submit should I
First Insert Product in Products Collection and then
Push this Product in Nested Product of Categories collection.
_categoryCollection.Update(id, Update< Category>.Push…)
Question 2:
Or
We shouldn’t just have anything called “Product Collection”. Instead we should have only one Categories collection with Nested Products in it. And on submit just Push this new Product in respective Category.
Question 2.1 : What if we want to do this association for product with category after the product is added. ?
Or
Question 3:
Considering question one. Should we have CategoryId in Product entity ? does this makes any sense in No SQL concepts ?
I've always found this MongoDB article a good resource for such questions.
http://docs.mongodb.org/ecosystem/use-cases/product-catalog/
The questions you need to ask are, how will the data be accessed? What are my objects and how are they formed? Start with your programming first, create your classes (domain objects) and your access patterns, then worry about Mongo. You'll see, Mongo won't really get in your way. That is what is was meant to do.
So, going back to your scenario. If you know the categories are going to be big in number, need to be tightly controlled and manipulated often, then you could have a second collection for them and reference back to that collection's _id field in your category field in the product documents. Important is, the values themselves for the categories should be stored with each product document, in order to have fast reads due to one less query or the need to join the data.
Scott
A few considerations can be made here:
If a category has many products but a product cannot belong to more than one category, then
If number of products is not expected to be very large per category, then
Nest products inside category document
Else, use a different collection for products and use field 'categoryId' in them
Else, use use a different collection for products and use field 'categoryId' in them
Nest documents only when they have one definite parent and they are not huge or too many. Otherwise, the parent document will get huge with no way to control its size.
I have to model a product, which has properties that aren't listed in the Schema.org Product type. After seeking in many places, I didn't find anything that fits to my need.
How can I extend the Schema.org Product type?
You could always use other vocabularies (that offer the properties you need) in addition to Schema.org. But if you want to use only the vocabulary Schema.org, you have two options in general:
Propose new properties (or classes).
You can do this on Schema.org W3C Community Group’s mailing list, or on Schema.org’s GitHub issue tracker.
See: How can I get involved? How can I propose new schemas or other improvements?
If accepted, it might become part of the core (if it’s something "the most common web applications need"), or it might become an extension.
(deprecated!) Extend existing properties.
Extending existing properties is documented at http://schema.org/docs/old_extension.html, but note that this mechanism is considered outdated.
For specific types (including Product), you can use Schema.org’s additionalProperty property:
A property-value pair representing an additional characteristics of the entitity, e.g. a product feature or another characteristic for which there is no matching property in schema.org.
In my UML class diagrams I usually do object collections by placing the attribute name above the arrow that relates both classes (as opposed to the other notation that just adds the attribute with brackets indicating the multiplicity).
But I have cases in which there are more than one collection of the same kind of object. For example (a very simple example off the top of my head):
Let's say there is a course that has some students who applied for it (so I have a collection of students, let's say an attribute that is an ArrayList of Student, called "applied"). But also, I need to keep a separate collection of the students who actually attended the course (let's say, "attended": another attribute that is an ArrayList, or even a different collection type, like a Vector, of Student).
Should I just add all attribute names on the relationship line?
I'm looking to do this the standard UML way. Only clarifying this because I know UML rules can be flexible when we need them to.
UML does allow for multiple associations between classes using roles.
You would simply draw two arrows:
See here for a similar question where the diagram is taken from.
I have two tables/collections; Users and Groups. A user can be a member of any number of groups and a user can also be an owner of any number of groups. In a relational database I'd probably have a third table called UserGroups with a UserID column, a GroupID column and an IsOwner column.
I'm using MongoDB and I'm sure there is a different approach for this kind of relationship in a document database. Should I embed the list of groups and groups-as-owner inside the Users table as two arrays of ObjectIDs? Should I also store the list of members and owners in the Groups table as two arrays, effectively mirroring the relationship causing a duplication of relationship information?
Or is a bridging UserGroups table a legitimate concept in document databases for many to many relationships?
Thanks
What I've seen done, and what I currently use are embedded arrays with node id's in each document.
So document user1 has property groups: [id1,id2]
And document group1 has property users: [user1]. Document group2 also has property users: [user1].
This way you get a Group object and easily select all related users, and the same for the User.
This takes a bit more work when creating and updating the object. When you say 2 objects are related, you have to update both objects.
There's also a concept DBReferences in MongoDB and depending on your driver, it'll pull referenced objects automatically when retrieving a document.
http://www.mongodb.org/display/DOCS/Database+References#DatabaseReferences-DBRef
In-case anyone interested, I just bumped into a very good article posted in mongoDB blog. 6 Rules of Thumb for MongoDB Schema Design. There are 3 parts in this article, after reading all 3 you'll have a good understanding.
Let's understand Many to Many Relations with an examples
books to authors
students to teachers
The books to authors is a few to few relationship, so we can have either an array of books or authors inside another's document. Same goes for students to teachers. We could also embed at the risk of duplication. However this will required that each student has a teacher in the system before insertion and vice versa. The application logic may always not allow it. In other words, the parent object must exist for the child object to exist.
But when you have many to many relationship, use two collections and have a true linking.
I've download a trial of Altova UModel and am starting using UML. As a practical beginning I am modelling a personal information manager application, which includes a web bookmark managing.
A Bookmark can belong to many (or no) Tags at once and a Tag can contain many (or no if all the bookmarks it contained were deleted) bookmarks. The relation has to be both-way navigable - a user has to be able to see all Bookmarks with a particular Tags ans all Tags of a Bookmark.
What is the correct UML relation between Bookmark and Tag classes?
As far as I understand UML now, it is an Association (not an Aggregation). But for a 2-way navigable many-to-many relation I can specify ends roles as "memberEnd" or "when navigableOwnedEnd", graphically the connection looks the same in both cases (an arrow) (which as I understand means navigability) but a property appears in the class box in case only when "memberEnd" is used.
How should I specif it in the model If I mean both-way navigable many-to-many relation there?
From UML Superstructure Specification, v2.1.2 section 7.3.3:
memberEnd : Property [2..*]
Each end represents participation of instances of the classifier connected to the end in links of the association. This is ordered association. Subsets Namespace::member.
ownedEnd : Property [*]
The ends that are owned by the association itself. This is an ordered association. Subsets Association::memberEnd,
Classifier::feature, and Namespace::ownedMember.
navigableOwnedEnd : Property [*]
The navigable ends that are owned by the association itself. Subsets Association::ownedEnd.
So if the end is 'owned' by the association, use the ownedEnd/navigableOwnedEnd type, otherwise use the memberEnd type.
Either can be used for a 'both-way navigable many-to-many relation'; if each relation link is a separate instance in your design, it can own the ends (e.g. class A and class B has a reference to a list of pairs of references to related As and Bs), but if the relation link is implicit then it does not own anything (e.g. class A has a list of references to related Bs, class B has a list of references to related As).
Having used UML since the late `90s, you're the first person I've met who cared about the difference!