그누보드에서 이런 시도 처음^^.....회원 가족관계를 프로필에 띄워 주려면.....?

그누보드에서 이런 시도 처음^^.....회원 가족관계를 프로필에 띄워 주려면.....?

QA

그누보드에서 이런 시도 처음^^.....회원 가족관계를 프로필에 띄워 주려면.....?

본문

 

여러 검색을 해봤지만...아직 그누보드에서 이런 시도는 없었던 것 같습니다. ㅠㅠ

그누보드 고수님들의 도움이 절실합니다. 한수 부탁드립니다........ ( _ _ )

 

1. 회원이 직접 가족관계 설정

회원은 실명을 한다는 전제. 어프라인으로 서로의 아이디를 알고 있다는 전제. 이상의 조건으로 회원이 직접 가족 아이디/실명을 검색하여 가족관계를 설정하게 한다! 는 로직1.

 

2. 관리자가 가족관계 설정

관리자/ 권한이 있는 중간관리자들이 실명/개인정보 확인하여 하나하나 가족관계를 설정하는 로직2.

 

2가지 전제 중 하나를 선택/ 또는 동시 가능??.....회원 정보DB는...

 

1. 회원정보 DB 테이블에 가족관계 테이블 추가

2. 회원 여분필드 활용

3. 태그 활용?

 

이렇게 3가지 가능성을 생각해 보았습니다.

적용범위는 3-4대까지의 가족관계를 나타낼 수 있는 정도면 충분하지 않을까 하는 생각입니다.

 

회원정보 프로필에 회원의 가족들 아이디(실명), 사진(아바타)가 보이게(관리자가 전체공개/권한설정된 회원만 보이게 설정) 구현! 

 

이 정도가 제가 정리한 생각들이구요.... 그누보드의 잠재성과 확장성을 위해 ....

고수님들... 한 수 부탁드립니다.

 

스킨 또는 플러그인으로 제작하면 많은 분들이 환영할 것 같습니다^^

지역공동체커뮤니티, 교회/사찰, 지역동아리 등 많은 곳에서 활용될 수 있을 것 같습니다.

물론 익명성보장이 디지털의 문화의 장점이라고는 하지만 때론 관리자나 리더쉽은 공동체의 관계를 더 잘 파악하여야 할 때가 있는 것 같습니다. 

 

글을 쓰다보니 QA가 아니라.... 제작의뢰 비슷한게 되어 버렸네요...(구차한 변명... 가족관계 테이블쿼리를 질문하려 했으나...)

 

 

이 질문에 댓글 쓰기 :

답변 5

https://dev.mysql.com/doc/refman/8.0/en/with.html

검토해 보세요.

남의 의견과 제안에 비난과 비판만 할게 아니라 "함께하고 연대하고 공유"하는 스피~릿. 그게. 개발자 정신 아닐까요?

개발의 개. 자도 모르는 사람이지만. 2006년도 부터 그누보드로 취미삼아 홈페이지를 만들어 오던 사람으로서 요즘 드는 생각입니다. 

stackkoverflow 검색해 봤는데 이렇더군요. 계속해볼겁니다. 그리고.... 비난하시는 분들. 내 아이디어 훔쳐서 돈 벌 생각마쇼 ㅋ^^

https://stackoverflow.com/questions/8558777/sql-members-table-to-show-family-relationships-between-members

쳇. 녀석에게 물어보니 아래와 같이 답.. 기록해 둡니다.

To create a SQL member table statement that shows family relationships between members, we'll create two tables: one for storing the member information, and another for storing the family relationships between members. Here's an example of how you can create these tables in MySQL:

-- Creating the Member table


CREATE TABLE Members (
  member_id INT AUTO_INCREMENT PRIMARY KEY,
  first_name VARCHAR(255) NOT NULL,
  last_name VARCHAR(255) NOT NULL,
  birth_date DATE,
  gender ENUM('M', 'F', 'O', 'U') NOT NULL
);

-- Creating the FamilyRelationships table


CREATE TABLE FamilyRelationships (
  relationship_id INT AUTO_INCREMENT PRIMARY KEY,
  member1_id INT,
  member2_id INT,
  relationship_type ENUM('SPOUSE', 'CHILD', 'PARENT', 'SIBLING') NOT NULL,
  FOREIGN KEY (member1_id) REFERENCES Members (member_id),
  FOREIGN KEY (member2_id) REFERENCES Members (member_id)
);

--------------

The Members table stores basic information about each family member, such as their ID, first name, last name, birth date, and gender. The FamilyRelationships table stores the relationship information between pairs of family members, with relationship types including 'SPOUSE', 'CHILD', 'PARENT', and 'SIBLING'.

The relationship_id is the primary key for the FamilyRelationships table, and member1_id and member2_id are foreign keys referencing the member_id in the Members table, ensuring the relationships are connected to valid member entries.

--------------

회원 간 가족 관계를 설정하려면 먼저 위에서 제안한 MembersFamilyRelationships 테이블을 사용하여 관계를 데이터베이스에 저장합니다. 그런 다음 프로필에 표시될 내용을 조회하기 위해 SQL 쿼리를 작성합니다.

먼저 예를 들어 앨리스가 밥의 딸이라면 다음과 같이 데이터를 입력할 수 있습니다.

--------------

-- Inserting Member data


INSERT INTO Members (first_name, last_name, birth_date, gender)
VALUES ('Alice', 'Smith', '2010-01-01', 'F'),
       ('Bob', 'Smith', '1980-02-15', 'M');
-- Inserting FamilyRelationship data
INSERT INTO FamilyRelationships (member1_id, member2_id, relationship_type)
VALUES (1, 2, 'CHILD'),
       (2, 1, 'PARENT');

--------------------

그런 다음 프로필에 가족 관계를 표시하기 위해 다음과 같은 SQL 쿼리를 사용할 수 있습니다.

---------------------


-- Query for Alice's profile (assuming Alice's member_id is 1)
SELECT m2.first_name, m2.last_name, m2.birth_date, m2.gender, fr.relationship_type
FROM FamilyRelationships fr
JOIN Members m1 ON fr.member1_id = m1.member_id
JOIN Members m2 ON fr.member2_id = m2.member_id
WHERE m1.member_id = 1;
-- Query for Bob's profile (assuming Bob's member_id is 2)
SELECT m2.first_name, m2.last_name, m2.birth_date, m2.gender, fr.relationship_type
FROM FamilyRelationships fr
JOIN Members m1 ON fr.member1_id = m1.member_id
JOIN Members m2 ON fr.member2_id = m2.member_id
WHERE m1.member_id = 2;

-----------------------------

위 쿼리를 사용하면 각 프로필에 대한 가족 관계가 반환되어 출력됩니다. 이 쿼리를 프로그램에서 실행한 다음 결과를 사용하여 프로필 페이지에 가족 관계와 함께 사진을 표시할 수 있습니다. 이 쿼리를 프로그램에 포함시켜 회원의 가족 관계가 정확하게 표시되도록 해야 합니다.

 

----------------------------

Yes, it's possible to implement 4th cousins with the code I suggested, but it requires some modifications to the FamilyRelationships table and the way you store and query the relationships.

First, you'll need to change the relationship_type in the FamilyRelationships table to include more specific types:


-- Recreate the FamilyRelationships table
DROP TABLE IF EXISTS FamilyRelationships;
CREATE TABLE FamilyRelationships (
  relationship_id INT AUTO_INCREMENT PRIMARY KEY,
  member1_id INT,
  member2_id INT,
  relationship_type ENUM('SPOUSE', 'MOTHER', 'FATHER', 'SISTER', 'BROTHER') NOT NULL,
  FOREIGN KEY (member1_id) REFERENCES Members (member_id),
  FOREIGN KEY (member2_id) REFERENCES Members (member_id)
);

In this case, we've changed the relationship types to 'MOTHER', 'FATHER', 'SISTER', and 'BROTHER', which will help to build the family tree more accurately.

Now, let's assume you have a family tree with all the required members and their relationships stored in the Members and FamilyRelationships tables. To find 4th cousins, you would need to traverse the family tree by querying the parent-child relationships repeatedly. This can be done using recursive Common Table Expressions (CTEs) in MySQL.

Here's an example of how you can find the 4th cousins for a given member (let's say their member_id is 1):


WITH RECURSIVE FamilyTree AS (
  SELECT member_id, first_name, last_name, birth_date, gender, 0 AS generation
  FROM Members
  WHERE member_id = 1
  UNION ALL
  SELECT m.member_id, m.first_name, m.last_name, m.birth_date, m.gender, ft.generation + 1
  FROM Members m
  JOIN FamilyRelationships fr ON (m.member_id = fr.member1_id AND fr.relationship_type IN ('MOTHER', 'FATHER'))
  JOIN FamilyTree ft ON fr.member2_id = ft.member_id
),
Cousins AS (
  SELECT ft1.member_id AS cousin1_id, ft2.member_id AS cousin2_id, ft1.generation AS cousin1_generation, ft2.generation AS cousin2_generation
  FROM FamilyTree ft1
  JOIN FamilyTree ft2 ON ft1.member_id <> ft2.member_id
  WHERE ft1.generation - ft2.generation = 4 OR ft2.generation - ft1.generation = 4
)
SELECT m1.first_name AS cousin1_first_name, m1.last_name AS cousin1_last_name, m2.first_name AS cousin2_first_name, m2.last_name AS cousin2_last_name
FROM Cousins c
JOIN Members m1 ON c.cousin1_id = m1.member_id
JOIN Members m2 ON c.cousin2_id = m2.member_id;

In this example, the FamilyTree CTE recursively builds the family tree for the given member by finding their ancestors, and the Cousins CTE finds pairs of members that are 4 generations apart. The final query returns the names of the 4th cousins.

Keep in mind that this query may not be very efficient if you have a large family tree, as it requires traversing the entire tree. It's also worth noting that this solution assumes there are no duplicate relationships or loops in the family tree.

답변을 작성하시기 전에 로그인 해주세요.
전체 116
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT