Designing an auto-related tableInventory database structure when inventory items have varying...

text{ } subscript size in tikzmath macro is not correct

Microphone on Mars

Uncountable set with a non-discrete metric

Automated testing of chained Queueable jobs in Salesforce

How bad is a Computer Science course that doesn't teach Design Patterns?

Under which circumstances can »werden« stand at the end of a sentence?

Badly designed reimbursement form. What does that say about the company?

"Happy is as happy does" What does this mean?

Buying a "Used" Router

Can I legally make a website about boycotting a certain company?

Why does RAM (any type) access time decrease so slowly?

Ramanujan's radical and how we define an infinite nested radical

How can I make my enemies feel real and make combat more engaging?

Manager has noticed coworker's excessive breaks. Should I warn him?

Why Third 'Reich'? Why is 'reich' not translated when 'third' is? What is the English synonym of reich?

Why did some CPUs use two Read/Write lines, and others just one?

Self-join example review in Books Online

Does changing "sa" password require a SQL restart (in mixed mode)?

Have a different color before and after a div with CSS

Are encryption algorithms with fixed-point free permutations inherently flawed?

Does the kobold player race feature, Pack Tactics, give ranged attacks advantage?

Rudeness by being polite

Failing PhD, how to go forward?

Can a planet be tidally unlocked?



Designing an auto-related table


Inventory database structure when inventory items have varying attributesSupertype/Subtype deciding between category: complete disjoint or incomplete overlappingSeparate archive tables or soft delete for inventory databaseSchema design: Use of association (aka: bridge/junction) table vs foreign key constraint with composite index containing a non-key fieldMySQL many to many relationOne or several tables for attributesHow do I guarantee inventory numbers are unique across all tables?inner join shows more entriesDatabase Design DilemaFeedback for db design













3















I'm a newbie in database design but I need to design one.
I need to have a record of the devices connected to a network in which certain device could be connected to many devices or any.



In the device's table I've got the following columns:



Device ID(char 25), 
IP address (char 25),
SN (PRIMARY KEY char 20)


All that information is taken from two CISCO commands (CDP show neighbors detail and show inventory) the info is placed in two text files.



The first file has the information of the device I'm connecting to via telnet and looks like this:



SN: FDO1129Z9ZJ
Device ID: Barragan_3750
IP: 148.227.2.158


The second file contains information about devices connected to this device, something like this:



Device ID: BIOTERIO
IP address: 148.228.83.189
Interface: GigabitEthernet1/0/6
Port ID (outgoing port): GigabitEthernet0/1
SN: P7K08UQ

Device ID: LAB_PESADO
IP address: 148.228.130.158
Interface: GigabitEthernet1/0/11
Port ID (outgoing port): GigabitEthernet0/1
SN: FNS174202FT

Device ID: Arquitectura_Salones
IP address: 148.228.1420.11
Interface: GigabitEthernet1/0/9
Port ID (outgoing port): GigabitEthernet0/49
SN: FNS14420420


I'm not sure how to represent the relationship because Interface (char 25) and Port ID (char 25) should be relationship's attributes.



Could you help me?










share|improve this question





























    3















    I'm a newbie in database design but I need to design one.
    I need to have a record of the devices connected to a network in which certain device could be connected to many devices or any.



    In the device's table I've got the following columns:



    Device ID(char 25), 
    IP address (char 25),
    SN (PRIMARY KEY char 20)


    All that information is taken from two CISCO commands (CDP show neighbors detail and show inventory) the info is placed in two text files.



    The first file has the information of the device I'm connecting to via telnet and looks like this:



    SN: FDO1129Z9ZJ
    Device ID: Barragan_3750
    IP: 148.227.2.158


    The second file contains information about devices connected to this device, something like this:



    Device ID: BIOTERIO
    IP address: 148.228.83.189
    Interface: GigabitEthernet1/0/6
    Port ID (outgoing port): GigabitEthernet0/1
    SN: P7K08UQ

    Device ID: LAB_PESADO
    IP address: 148.228.130.158
    Interface: GigabitEthernet1/0/11
    Port ID (outgoing port): GigabitEthernet0/1
    SN: FNS174202FT

    Device ID: Arquitectura_Salones
    IP address: 148.228.1420.11
    Interface: GigabitEthernet1/0/9
    Port ID (outgoing port): GigabitEthernet0/49
    SN: FNS14420420


    I'm not sure how to represent the relationship because Interface (char 25) and Port ID (char 25) should be relationship's attributes.



    Could you help me?










    share|improve this question



























      3












      3








      3








      I'm a newbie in database design but I need to design one.
      I need to have a record of the devices connected to a network in which certain device could be connected to many devices or any.



      In the device's table I've got the following columns:



      Device ID(char 25), 
      IP address (char 25),
      SN (PRIMARY KEY char 20)


      All that information is taken from two CISCO commands (CDP show neighbors detail and show inventory) the info is placed in two text files.



      The first file has the information of the device I'm connecting to via telnet and looks like this:



      SN: FDO1129Z9ZJ
      Device ID: Barragan_3750
      IP: 148.227.2.158


      The second file contains information about devices connected to this device, something like this:



      Device ID: BIOTERIO
      IP address: 148.228.83.189
      Interface: GigabitEthernet1/0/6
      Port ID (outgoing port): GigabitEthernet0/1
      SN: P7K08UQ

      Device ID: LAB_PESADO
      IP address: 148.228.130.158
      Interface: GigabitEthernet1/0/11
      Port ID (outgoing port): GigabitEthernet0/1
      SN: FNS174202FT

      Device ID: Arquitectura_Salones
      IP address: 148.228.1420.11
      Interface: GigabitEthernet1/0/9
      Port ID (outgoing port): GigabitEthernet0/49
      SN: FNS14420420


      I'm not sure how to represent the relationship because Interface (char 25) and Port ID (char 25) should be relationship's attributes.



      Could you help me?










      share|improve this question
















      I'm a newbie in database design but I need to design one.
      I need to have a record of the devices connected to a network in which certain device could be connected to many devices or any.



      In the device's table I've got the following columns:



      Device ID(char 25), 
      IP address (char 25),
      SN (PRIMARY KEY char 20)


      All that information is taken from two CISCO commands (CDP show neighbors detail and show inventory) the info is placed in two text files.



      The first file has the information of the device I'm connecting to via telnet and looks like this:



      SN: FDO1129Z9ZJ
      Device ID: Barragan_3750
      IP: 148.227.2.158


      The second file contains information about devices connected to this device, something like this:



      Device ID: BIOTERIO
      IP address: 148.228.83.189
      Interface: GigabitEthernet1/0/6
      Port ID (outgoing port): GigabitEthernet0/1
      SN: P7K08UQ

      Device ID: LAB_PESADO
      IP address: 148.228.130.158
      Interface: GigabitEthernet1/0/11
      Port ID (outgoing port): GigabitEthernet0/1
      SN: FNS174202FT

      Device ID: Arquitectura_Salones
      IP address: 148.228.1420.11
      Interface: GigabitEthernet1/0/9
      Port ID (outgoing port): GigabitEthernet0/49
      SN: FNS14420420


      I'm not sure how to represent the relationship because Interface (char 25) and Port ID (char 25) should be relationship's attributes.



      Could you help me?







      mysql database-design






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 8 mins ago









      MDCCL

      6,76731745




      6,76731745










      asked Feb 28 '17 at 16:37









      Cesar Alejandro Villegas YepezCesar Alejandro Villegas Yepez

      336




      336






















          1 Answer
          1






          active

          oldest

          votes


















          2














          If I were you I would break this into a minimum of three tables:




          1. Devices

          2. Ports

          3. Interfaces


          You have already got most of the data you will need, I do suggest also considering the MAC address of different ports where available.



          If I were building these out, I would use the following fields:



              CREATE TABLE device {
          serial_num VARCHAR(25) PRIMARY KEY,
          device_id VARCHAR(255) UNIQUE KEY,
          ip_add BINARY(16)
          };

          CREATE TABLE ports {
          device_serial VARCHAR(25) NOT NULL,
          port_id INT NOT NULL,
          port_type varchar(40),
          port_num varchar(15),
          mac_add BINARY(48),
          PRIMARY KEY (device_serial, port_id),
          UNIQUE KEY (mac_add)
          };

          CREATE TABLE interfaces {
          interface_id INT NOT NULL PRIMARY KEY,
          interface_name VARCHAR(255),
          port_a INT,
          port_b INT,
          ip_add BINARY(16),
          UNIQUE KEY (port_a, port_b)
          };


          This would allow you to specify most of the fields with a degree of specificity.



          Each "device" could either be a router or a switch, or even an end user device, as far as the network is concerned it's simply something which can be connected. It might benefit you to add an ENUM type to let you easily assign a status to each device as well, however for now you can keep it simple.



          Since most ports will have a MAC address, and MAC addresses are globally unique, it would make sense to give each MAC address a unique key, allowing it to be nullable allows you to use serial ports and the like as well which don't have MAC addresses afaik. The point of the composite Primary key in the ports table is to tie each port to a device, that way ports are not allowed to float around on theIr own confusing the net admins.



          The Interfaces table is how things tie together, an interface is simplY a connection between two ports. I gave the interface the IP address, as monitoring of a device over TCP/IP tends to start from seeing if the IP address is responding and it makes the most sense, it also helps to make sure only one pair of ports are using an IP address at a time.



          A few notes on this design, you will need to use some scripting language to make full use of this, I determined to use a binary datatype for IP and MAC addresses based on a useful answer on our sister site. Likewise, converting a MAC Address back and forth can be done with this PHP function.



          There are certainly improvements which could be made to this design, however I think it serves as a good boilerplate for a simple network management DB.






          share|improve this answer

























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "182"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f165751%2fdesigning-an-auto-related-table%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            If I were you I would break this into a minimum of three tables:




            1. Devices

            2. Ports

            3. Interfaces


            You have already got most of the data you will need, I do suggest also considering the MAC address of different ports where available.



            If I were building these out, I would use the following fields:



                CREATE TABLE device {
            serial_num VARCHAR(25) PRIMARY KEY,
            device_id VARCHAR(255) UNIQUE KEY,
            ip_add BINARY(16)
            };

            CREATE TABLE ports {
            device_serial VARCHAR(25) NOT NULL,
            port_id INT NOT NULL,
            port_type varchar(40),
            port_num varchar(15),
            mac_add BINARY(48),
            PRIMARY KEY (device_serial, port_id),
            UNIQUE KEY (mac_add)
            };

            CREATE TABLE interfaces {
            interface_id INT NOT NULL PRIMARY KEY,
            interface_name VARCHAR(255),
            port_a INT,
            port_b INT,
            ip_add BINARY(16),
            UNIQUE KEY (port_a, port_b)
            };


            This would allow you to specify most of the fields with a degree of specificity.



            Each "device" could either be a router or a switch, or even an end user device, as far as the network is concerned it's simply something which can be connected. It might benefit you to add an ENUM type to let you easily assign a status to each device as well, however for now you can keep it simple.



            Since most ports will have a MAC address, and MAC addresses are globally unique, it would make sense to give each MAC address a unique key, allowing it to be nullable allows you to use serial ports and the like as well which don't have MAC addresses afaik. The point of the composite Primary key in the ports table is to tie each port to a device, that way ports are not allowed to float around on theIr own confusing the net admins.



            The Interfaces table is how things tie together, an interface is simplY a connection between two ports. I gave the interface the IP address, as monitoring of a device over TCP/IP tends to start from seeing if the IP address is responding and it makes the most sense, it also helps to make sure only one pair of ports are using an IP address at a time.



            A few notes on this design, you will need to use some scripting language to make full use of this, I determined to use a binary datatype for IP and MAC addresses based on a useful answer on our sister site. Likewise, converting a MAC Address back and forth can be done with this PHP function.



            There are certainly improvements which could be made to this design, however I think it serves as a good boilerplate for a simple network management DB.






            share|improve this answer






























              2














              If I were you I would break this into a minimum of three tables:




              1. Devices

              2. Ports

              3. Interfaces


              You have already got most of the data you will need, I do suggest also considering the MAC address of different ports where available.



              If I were building these out, I would use the following fields:



                  CREATE TABLE device {
              serial_num VARCHAR(25) PRIMARY KEY,
              device_id VARCHAR(255) UNIQUE KEY,
              ip_add BINARY(16)
              };

              CREATE TABLE ports {
              device_serial VARCHAR(25) NOT NULL,
              port_id INT NOT NULL,
              port_type varchar(40),
              port_num varchar(15),
              mac_add BINARY(48),
              PRIMARY KEY (device_serial, port_id),
              UNIQUE KEY (mac_add)
              };

              CREATE TABLE interfaces {
              interface_id INT NOT NULL PRIMARY KEY,
              interface_name VARCHAR(255),
              port_a INT,
              port_b INT,
              ip_add BINARY(16),
              UNIQUE KEY (port_a, port_b)
              };


              This would allow you to specify most of the fields with a degree of specificity.



              Each "device" could either be a router or a switch, or even an end user device, as far as the network is concerned it's simply something which can be connected. It might benefit you to add an ENUM type to let you easily assign a status to each device as well, however for now you can keep it simple.



              Since most ports will have a MAC address, and MAC addresses are globally unique, it would make sense to give each MAC address a unique key, allowing it to be nullable allows you to use serial ports and the like as well which don't have MAC addresses afaik. The point of the composite Primary key in the ports table is to tie each port to a device, that way ports are not allowed to float around on theIr own confusing the net admins.



              The Interfaces table is how things tie together, an interface is simplY a connection between two ports. I gave the interface the IP address, as monitoring of a device over TCP/IP tends to start from seeing if the IP address is responding and it makes the most sense, it also helps to make sure only one pair of ports are using an IP address at a time.



              A few notes on this design, you will need to use some scripting language to make full use of this, I determined to use a binary datatype for IP and MAC addresses based on a useful answer on our sister site. Likewise, converting a MAC Address back and forth can be done with this PHP function.



              There are certainly improvements which could be made to this design, however I think it serves as a good boilerplate for a simple network management DB.






              share|improve this answer




























                2












                2








                2







                If I were you I would break this into a minimum of three tables:




                1. Devices

                2. Ports

                3. Interfaces


                You have already got most of the data you will need, I do suggest also considering the MAC address of different ports where available.



                If I were building these out, I would use the following fields:



                    CREATE TABLE device {
                serial_num VARCHAR(25) PRIMARY KEY,
                device_id VARCHAR(255) UNIQUE KEY,
                ip_add BINARY(16)
                };

                CREATE TABLE ports {
                device_serial VARCHAR(25) NOT NULL,
                port_id INT NOT NULL,
                port_type varchar(40),
                port_num varchar(15),
                mac_add BINARY(48),
                PRIMARY KEY (device_serial, port_id),
                UNIQUE KEY (mac_add)
                };

                CREATE TABLE interfaces {
                interface_id INT NOT NULL PRIMARY KEY,
                interface_name VARCHAR(255),
                port_a INT,
                port_b INT,
                ip_add BINARY(16),
                UNIQUE KEY (port_a, port_b)
                };


                This would allow you to specify most of the fields with a degree of specificity.



                Each "device" could either be a router or a switch, or even an end user device, as far as the network is concerned it's simply something which can be connected. It might benefit you to add an ENUM type to let you easily assign a status to each device as well, however for now you can keep it simple.



                Since most ports will have a MAC address, and MAC addresses are globally unique, it would make sense to give each MAC address a unique key, allowing it to be nullable allows you to use serial ports and the like as well which don't have MAC addresses afaik. The point of the composite Primary key in the ports table is to tie each port to a device, that way ports are not allowed to float around on theIr own confusing the net admins.



                The Interfaces table is how things tie together, an interface is simplY a connection between two ports. I gave the interface the IP address, as monitoring of a device over TCP/IP tends to start from seeing if the IP address is responding and it makes the most sense, it also helps to make sure only one pair of ports are using an IP address at a time.



                A few notes on this design, you will need to use some scripting language to make full use of this, I determined to use a binary datatype for IP and MAC addresses based on a useful answer on our sister site. Likewise, converting a MAC Address back and forth can be done with this PHP function.



                There are certainly improvements which could be made to this design, however I think it serves as a good boilerplate for a simple network management DB.






                share|improve this answer















                If I were you I would break this into a minimum of three tables:




                1. Devices

                2. Ports

                3. Interfaces


                You have already got most of the data you will need, I do suggest also considering the MAC address of different ports where available.



                If I were building these out, I would use the following fields:



                    CREATE TABLE device {
                serial_num VARCHAR(25) PRIMARY KEY,
                device_id VARCHAR(255) UNIQUE KEY,
                ip_add BINARY(16)
                };

                CREATE TABLE ports {
                device_serial VARCHAR(25) NOT NULL,
                port_id INT NOT NULL,
                port_type varchar(40),
                port_num varchar(15),
                mac_add BINARY(48),
                PRIMARY KEY (device_serial, port_id),
                UNIQUE KEY (mac_add)
                };

                CREATE TABLE interfaces {
                interface_id INT NOT NULL PRIMARY KEY,
                interface_name VARCHAR(255),
                port_a INT,
                port_b INT,
                ip_add BINARY(16),
                UNIQUE KEY (port_a, port_b)
                };


                This would allow you to specify most of the fields with a degree of specificity.



                Each "device" could either be a router or a switch, or even an end user device, as far as the network is concerned it's simply something which can be connected. It might benefit you to add an ENUM type to let you easily assign a status to each device as well, however for now you can keep it simple.



                Since most ports will have a MAC address, and MAC addresses are globally unique, it would make sense to give each MAC address a unique key, allowing it to be nullable allows you to use serial ports and the like as well which don't have MAC addresses afaik. The point of the composite Primary key in the ports table is to tie each port to a device, that way ports are not allowed to float around on theIr own confusing the net admins.



                The Interfaces table is how things tie together, an interface is simplY a connection between two ports. I gave the interface the IP address, as monitoring of a device over TCP/IP tends to start from seeing if the IP address is responding and it makes the most sense, it also helps to make sure only one pair of ports are using an IP address at a time.



                A few notes on this design, you will need to use some scripting language to make full use of this, I determined to use a binary datatype for IP and MAC addresses based on a useful answer on our sister site. Likewise, converting a MAC Address back and forth can be done with this PHP function.



                There are certainly improvements which could be made to this design, however I think it serves as a good boilerplate for a simple network management DB.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 23 '17 at 12:40









                Community

                1




                1










                answered Feb 28 '17 at 17:46









                JPeck89JPeck89

                1128




                1128






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Database Administrators Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f165751%2fdesigning-an-auto-related-table%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Parapolítica Índice Antecedentes El escándalo Proceso judicial Consecuencias Véase...

                    How to remove border from elements in the last row?Targeting flex items on the last rowHow to vertically wrap...

                    Tecnologías entrañables Índice Antecedentes Desarrollo Tecnologías Entrañables en la...