Line 1: |
Line 1: |
− | =Database Basic= | + | =Database Basics= |
| *Relational databases (e.g. MySQL) are probably the most common. Essentially they store data in a set of 2D tables (relations) that follow certain rules of normalization and can be linked to each other via relational algebra (mostly set theory type functions). | | *Relational databases (e.g. MySQL) are probably the most common. Essentially they store data in a set of 2D tables (relations) that follow certain rules of normalization and can be linked to each other via relational algebra (mostly set theory type functions). |
| *To address problems encountered when trying to interface a RDBMS with an object-oriented programming language, alternative non-relational database structures (e.g. XML, NoSQL, Hierarchical, Network) are available and may have advantages in certain situations. | | *To address problems encountered when trying to interface a RDBMS with an object-oriented programming language, alternative non-relational database structures (e.g. XML, NoSQL, Hierarchical, Network) are available and may have advantages in certain situations. |
Line 7: |
Line 7: |
| *Databases can be indexed to streamline queries. | | *Databases can be indexed to streamline queries. |
| | | |
− | =Useful Wikipedia Pages= | + | =Useful Resources= |
| *[https://en.wikipedia.org/wiki/Relation_(database) Relation] | | *[https://en.wikipedia.org/wiki/Relation_(database) Relation] |
| *[https://en.wikipedia.org/wiki/Database_normalization#Satisfying_EKNF Database Normalization w/ step by step instructions w/ examples] | | *[https://en.wikipedia.org/wiki/Database_normalization#Satisfying_EKNF Database Normalization w/ step by step instructions w/ examples] |
Line 14: |
Line 14: |
| *[https://en.wikipedia.org/wiki/Database_index Database Indexing] | | *[https://en.wikipedia.org/wiki/Database_index Database Indexing] |
| *[https://en.wikipedia.org/wiki/Relational_database Relational Database, lengthy overview] | | *[https://en.wikipedia.org/wiki/Relational_database Relational Database, lengthy overview] |
| + | *[https://rstsaygili.medium.com/many-to-many-relationships-in-relational-databases-af867547914f Resolving Many-To-Many Relationships] |
| + | *[https://builtin.com/data-science/sql-vs-nosql SQL vs NoSQL] |
| | | |
| =Working Prototype= | | =Working Prototype= |
Line 26: |
Line 28: |
| ! Attribute !! Domain !! Cardinality | | ! Attribute !! Domain !! Cardinality |
| |- | | |- |
− | | Disease (PK) || text || M2M | + | | Disease (PK) || text || -- |
| |- | | |- |
| | Risk factors || text || M2M | | | Risk factors || text || M2M |
Line 46: |
Line 48: |
| | Studies || text || M2M | | | Studies || text || M2M |
| |} | | |} |
| + | |
| + | Each primary key (disease) can be associated with multiple values in each attribute. For example, CAD is associated with multiple risk factors (age, male gender, smoking, etc) and multiple symptoms (angina, dyspnea, nausea, etc). At the same time, each of these risk factors and symptoms are associated with other diseases besides CAD. For example, smoking is a risk factor for CAD, lung cancer, PVD, COPD, head and neck cancer, etc. In order to handle this many-to-many cardinality of the data, multiple base tables should be created and an associative table (junction table) can then be created as needed. The base tables in the above example would be: |
| + | {| class="wikitable" |
| + | |+ Base Table 1 |
| + | |- |
| + | | Disease (PK) |
| + | |- |
| + | | Risk factors |
| + | |} |
| + | |
| + | {| class="wikitable" |
| + | |+ Base Table 2 |
| + | |- |
| + | | Risk factors (PK) |
| + | |- |
| + | | Disease |
| + | |} |
| + | |
| + | Disease < Symptom < Disease |