diff --git a/README.md b/README.md index 48bf11d..6e81813 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,14 @@ - `Items` can have `Tags`: Implemented ### To Implement -- Authenticated `Users` can create `Reviews` referencing one or more `Items` and `Tag` them (for example with a URL linking to a more in-depth review) -- `Users` can trust (the reviews of) other users, creating a web of trust +- Authenticated `Users` can write `Reviews` referencing one or more `Items` and `Tag` them (for example with a URL linking to a more in-depth review) +- `Users` can trust (the reviews of) other users, + creating a web of trust ## Database Design -`Tags` are Key-Value like in [OpenStreetMap](https://wiki.openstreetmap.org/wiki/Tags) or Wikidata, +`Tags` are Key-Value like in [OpenStreetMap](https://wiki.openstreetmap.org/wiki/Tags) or Wikidata, that is why they need own tables. -Initially I planned having a shared `Tags` table for both `Reviews` and `Items`, +Initially I planned having a shared `Tags` table for both `Reviews` and `Items`, but that would have been impractical because a Tag either belongs to a Review or an Item, so two separate tables would have needed to been set up to track the referenced object, with a risk of anomalies: @@ -23,6 +24,13 @@ Considering the simplicity of a Tag, creating two separate tables prevents those cases without overhead and normalizes the schema. +![CompareWare Overview Entity Relationship Diagram](compareware-erd.png) + +Of course, every many-to-many relationship needs another table +to be represented in a normalized well, +which the diagram of the actual structure used in the code illustrates: + +TODO ## Developer Setup diff --git a/compareware.plantuml b/compareware-erd.plantuml similarity index 63% rename from compareware.plantuml rename to compareware-erd.plantuml index de45e24..e81366a 100644 --- a/compareware.plantuml +++ b/compareware-erd.plantuml @@ -8,15 +8,8 @@ left to right direction entity User { Id: Autoumber -- - Name - Pass -} - -entity Tag { - Id: Autoumber - -- - Key: String - Value: String + (UNIQUE) Name: String + Pass: String } entity Item { @@ -28,13 +21,26 @@ entity Review { Id: Autoumber -- (FK) AuthorId - Text + Text: String } +entity ItemTag { + Id: Autoumber + -- + (INDEX) Key: String + Value: String +} + +entity ReviewTag { + Id: Autoumber + -- + (INDEX) Key: String + Value: String +} User ||--o{ Review::AuthorId: Writes -Item --o{ Tag -Review --o{ Tag +Item ||--o{ ItemTag +Review ||--o{ ReviewTag Item }|--o{ Review User }|--|{ User: Trusts diff --git a/compareware-erd.png b/compareware-erd.png new file mode 100644 index 0000000..736f4b9 Binary files /dev/null and b/compareware-erd.png differ diff --git a/compareware-nf.plantuml b/compareware-nf.plantuml deleted file mode 100644 index eb46665..0000000 --- a/compareware-nf.plantuml +++ /dev/null @@ -1,62 +0,0 @@ -@startuml compareware-erd-nf -skinparam linetype ortho -hide circle -left to right direction -'!theme sandstone -!theme blueprint - -entity User { - Id: Autoumber - -- - Name - Pass -} - -entity Tag { - Id: Autoumber - -- - Key: String - Value: String -} - -entity ItemTag { - (FK) ReviewId - (FK) TagId - -- -} - -entity Item { - WikidataId: String - -- -} - -entity Review { - Id: Autoumber - -- - (FK) AuthorId - Text -} - -entity ReviewTag { - (FK) ReviewId - (FK) TagId - -- -} - -entity ItemReview { - (FK) ItemId - (FK) ReviewId - -- -} - - -User ||--o{ Review::AuthorId: Writes -Item ||--o{ ItemTag -Review ||--o{ ReviewTag -ItemTag::TagId ||--o| Tag::Id -ReviewTag::TagId ||--o| Tag::Id -Item::WikidataId ||--o{ ItemReview::ItemId -ItemReview::ReviewId }|--|| Review::Id -User }|--|{ User: Trusts - -@enduml