in Education by
I've been trying for days to design this database. I'm designing it in access then implementing on MYSQL Server as a PHP Web Application. I have a table: Members MemberID (autoNumber, PK) MemberName MemberDetails Members can have many relationships with other members, this may be Child, Parent, Friend, Spouse etc. Looking at one Member, I'd like to be able to create new relationships with existing members and then have that relationship also be visible from the related member without further input. Members should also be able to list all their relationships. Can you please advise how I should do this? I've tried a few options but none seem to work as intended. I'm comfortable with SQL, I'm just having trouble with the Unary relationship design. -edit- Also, I forgot to add, this is not going to be able to use INNODB due to server restrictions. Most likely will be MYISAM, though i still want referential integrity :( 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
Let the table members contain members data and the table relations contain member relations data. relations.member_id will be a reference to the member, relations.related_member_id - to the related member. relations.type is enumerable relation type. CREATE TABLE `members` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` TEXT NOT NULL , `details` TEXT NOT NULL ) ENGINE = INNODB; CREATE TABLE `relations` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `member_id` INT NOT NULL , `related_member_id` INT NOT NULL , `type` ENUM( 'Child', 'Parent', 'Friend', 'Spouse' ) NOT NULL, FOREIGN KEY (member_id) REFERENCES members(id), FOREIGN KEY (related_member_id) REFERENCES members(id) ) ENGINE = INNODB; UPD: MyISAM version (removed foreign keys, all possible foreign keys functionality should be handled by server side scripts): CREATE TABLE `members` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` TEXT NOT NULL , `details` TEXT NOT NULL ) ENGINE = MyISAM; CREATE TABLE `relations` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `member_id` INT NOT NULL , `related_member_id` INT NOT NULL , `type` ENUM( 'Child', 'Parent', 'Friend', 'Spouse' ) NOT NULL ) ENGINE = MyISAM;

Related questions

0 votes
    _________________ shows relationship between diff members of a family. a. Family tree b. Generations c. Uncle d. Aunt...
asked May 14, 2021 in General by JackTerrance
0 votes
    List the different types of relationships in SQL....
asked Dec 9, 2020 in Technology by JackTerrance
0 votes
    Which model is used when there contains relationships between entities? (1)External Model (2)All the Options (3)Reference Model (4)Embedded Model...
asked May 23, 2021 in Technology by JackTerrance
0 votes
    Which AI technique enables the computers to understand the associations and relationships between objects and ... Processing Cognitive Science Relative Symbolism Pattern Matching...
asked Mar 8, 2021 in Technology by JackTerrance
0 votes
    In SQL Server 2005, we can create temp tables one of two ways: declare @tmp table (Col1 int, Col2 ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
0 votes
    I am trying to run the following SQL: INSERT INTO Suppliers ( [SupplierID], [CompanyName]) Select [SupplierID], [ ... is very slow. Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    2 differences between static and nonstatic data members in Java Select the correct answer from above options...
asked Dec 16, 2021 in Education by JackTerrance
0 votes
    ________ is a type of intelligent technique that finds patterns and relationships in massive data sets too large for a ... to analyze. Select the correct answer from above options...
asked Dec 6, 2021 in Education by JackTerrance
0 votes
    ________ is a type of intelligent technique that finds patterns and relationships in massive data sets too large for a ... to analyze. Select the correct answer from above options...
asked Dec 5, 2021 in Education by JackTerrance
0 votes
    ________ is a type of intelligent technique that finds patterns and relationships in massive data sets too large for a ... to analyze. Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    Which of the following analysis is a statistical process for estimating the relationships among variables? (a) ... and answers pdf, Data Science interview questions for beginners...
asked Oct 29, 2021 in Education by JackTerrance
0 votes
    How many types of relationships available in Laravel Eloquent?...
asked Sep 30, 2021 in Technology by JackTerrance
0 votes
    How can you create many to many relationships under salesforce? (1)Creating direct many to many relationships (2) ... (4)Not possible to create many relationships in salesforce...
asked Aug 26, 2021 in Technology by JackTerrance
0 votes
    How can you create many to many relationships under salesforce? 1. Using a piece of code to relate both ... in salesforce 4. Creating direct many to many relationships...
asked Jun 27, 2021 in Technology by JackTerrance
0 votes
    What do Master-Detail relationships will involve? 1. Cascading deletes and sharing rules which are controlled by ... retail sectors 4. Relationship between master and slave drives...
asked Jun 27, 2021 in Technology by JackTerrance
...