in Education by
In my Rails app, I want to allow the user to connect to multiple remote locations via different protocols (FTP, SFTP, S3, Dropbox). Each location has different properties: FTP: host, port, username, password, is_passive SFTP: host, port, username, password S3: bucket, key (not sure these are right; I'm guessing) Dropbox: username, password (again, I'm guessing) What would be the more advantageous database table design for storing this information? Option 1 (master table with tables for each protocol) connection id name protocol ftp_connection connection_id host username password port is_passive sftp_connection connection_id host username password port s3_connection connection_id bucket key dropbox_connection connection_id username password Option 2 (master table with a 'properties' table) connection id name connection_properties id connection_id property_name property_value (don't worry, I'll be encrypting credentials) JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Your case looks like an instance of the Gen-Spec design pattern. Gen-spec is familiar to object oriented programmers through the superclass-subclass hierarchy. Unfortunately, introductions to relational database design tend to skip over how to design tables for the Gen-Spec situation. Fortunately, it’s well understood. A web search on “Relational database generalization specialization” will yield several articles on the subject. Some of your hits will be previous questions here on SO. The trick is in the way the PK for the subclass (specialized) tables gets assigned. It’s not generated by some sort of autonumber feature. Instead, it’s a copy of the PK in the superclass (generalized) table, and is therefore an FK reference to it. Thus, if the case were vehicles, trucks and sedans, every truck or sedan would have an entry in the vehicles table, trucks would also have an entry in the trucks table, with a PK that’s a copy of the corresponding PK in the vehicles table. Similarly for sedans and the sedan table. It’s easy to figure out whether a vehicle is a truck or a sedan by just doing joins, and you usually want to join the data in that kind of query anyway.

Related questions

0 votes
    I have a user model that has many fields (let's say 30 for this example). When the user signs ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    The database design that consists of multiple tables that are linked together through matching data stored in ... Hashing in division Indexing and Hashing of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    I want to know in spine how to add and remove active class for div. In the firebug I saw ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I am writing an API for an iOS app where the user's login with the Facebook API on iOS. The server ... achieve this kinda setup? Select the correct answer from above options...
asked Feb 3, 2022 in Education by JackTerrance
0 votes
    I am making various routes with a format like below: get "address/1000broadway" get "address/300main" This ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    While running the server, i am getting the error incompatible library version.Already Nokogiri is installed in ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I have 2 models: class Annotation include Mongoid::Document belongs_to :event field :desc, type: String end ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 23, 2022 in Education by JackTerrance
0 votes
    I got this query: User.collection.aggregate([ {"$project" => { "dayOfMonth" => {"$dayOfMonth" => ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    Here's my RubyGems Environment: RUBYGEMS VERSION: 2.5.2 RUBY VERSION: 2.2.2 (2015-04-13 ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    When trying to start rails console I keep getting the following error Users/rigelstpierre/.rvm/rubies/ruby-1 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    What is current state of the art for enabling OpenID login in Ruby on Rails applications? This is a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I know there are several plugins that do asynchronous processing. Which one is the best one and why? The ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I asked a question earlier, and got an excellent response, but, being a newbie to Rails and still ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 10, 2022 in Education by JackTerrance
...