Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EA4602009DC for ; Tue, 2 May 2017 18:07:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E8EE6160B9B; Tue, 2 May 2017 16:07:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 38BE2160BA1 for ; Tue, 2 May 2017 18:07:07 +0200 (CEST) Received: (qmail 86315 invoked by uid 500); 2 May 2017 16:07:06 -0000 Mailing-List: contact dev-help@ariatosca.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ariatosca.incubator.apache.org Delivered-To: mailing list dev@ariatosca.incubator.apache.org Received: (qmail 86304 invoked by uid 99); 2 May 2017 16:07:06 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 May 2017 16:07:06 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id E34AFC05A7 for ; Tue, 2 May 2017 16:07:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id l9bHzn_5Sb5b for ; Tue, 2 May 2017 16:07:05 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id BEDBF5F3BF for ; Tue, 2 May 2017 16:07:04 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 58625E0905 for ; Tue, 2 May 2017 16:07:04 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 0C01420D54 for ; Tue, 2 May 2017 16:07:04 +0000 (UTC) Date: Tue, 2 May 2017 16:07:04 +0000 (UTC) From: "Tal Liron (JIRA)" To: dev@ariatosca.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (ARIA-180) Convert many-to-many for parameter models to one-to-many MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 02 May 2017 16:07:08 -0000 Tal Liron created ARIA-180: ------------------------------ Summary: Convert many-to-many for parameter models to one-to-many Key: ARIA-180 URL: https://issues.apache.org/jira/browse/ARIA-180 Project: AriaTosca Issue Type: Story Reporter: Tal Liron Priority: Minor We must first discuss this as a team to see if we agree that this is the best solution. (There was an early discussion between Tal and Maxim.) First let's point out that one-to-many is a special case of many-to-many, so that everything works fine now and continue to work fine. However, logically our code right now treats them as one-to-many: there is no case in which a {{Parameter}} model belongs to more than one model. Parameters are always copied to the new model, for example during instantiation, or during task creation. There are cons to using many-to-many in our case: * We generate lots of extra secondary tables, one for each potential relationship * Crawling back from a `Parameter` to its containing model is quite costly, as it involves a new SQL query to check for each possible relationship * Logical confusion: if we do not write our code to support one parameter belonging to one model, and yet a user can create such a relationship, what would happen? * Slower The one advantage of many-to-many is that we *could* potentially optimize in some cases where the parameter has an identical value and we know would never change, and thus could safely link it multiple times instead of copying it. This optimization, however, requires us to be 100% sure that the parameter is immutable: otherwise, if a user changes it (for example in a task) it would change for all other containers. The questions are: 1) are we ever sure of immutability? and 2) is this optimization worth the effort of implementing it? The optimization would only seem to save some disk space. If we decide to switch to one-to-many, we have two approached: * Straightforward: one foreign key in {{Parameter}} per each possible containing relationship. Pros: naturally supported in SQL, cons: we will have lots of fk columns per row in the {{Parameter}} table, whereby only one will be non-null. * Polymorphic one-to-many (type-and-id joins): {{Parameter}} only has a single general-purpose fk column and another column specifying the type of the fk (node, interface, task, etc.). Cons: we would need to investigate how to accomplish this in SQLAlchemy. -- This message was sent by Atlassian JIRA (v6.3.15#6346)