0
How to decide classes for a family database
Hi Question is to design classes for making national database for each of the family...classes should have relations Below is my trial. Could you people please suggest on this ? https://code.sololearn.com/c1h5aZQp7mP4/?ref=app
11 odpowiedzi
+ 1
It depends really on the scope of data collection. I think a few fields may need to be added, in terms of civil registration.
ID Number (unique)
Nationality
Place of birth, adding to DoB
Blood group
Religion
Occupation
Full address (province, city)
Spouse (when married)
Children (when married)
<IsAdult> can rely on DoB.
<IsMarried> could be a flag rather than boolean, to support divorced couples.
+ 1
Thanks Ipang ...also Any suggestions of all data distribution among different classes? Specially distribution is something which was asked as question to me
+ 1
it's like how many classes are good to have all these information? We can have all data in one class, but it can be better if it is along different classes... So question was what all field and in which class? Also how those classes are related like aggregation or composition
+ 1
How many classes needed depends on the design.
I was thinking of citizen ID Number and Family ID Number, as that is roughly how civil registration system seem to work in my country (not sure how it works there).
Family card contains at least one member identified by citizen IDs.
Personal details are stored in other class e.g. clsCitizen which uniquely identifies a citizen by citizen ID.
I'm not sure about data integrity in codes, in RDBMS data integrity is supported.
+ 1
Thanks Ipang ...it helped.
Also not into rdbms , but into c++... Assume that we are suppose to design the system and accordingly we are open to choose classes for this entire system.
Updated code according to your suggestions.... Is it good now ? I doubt whether inheritance I used for family member class from human is good or not ?
+ 1
Ketan,
Not gonna say good or bad, don't know how to properly assess it.
Where is the need for inheritance here I'm not sure. We don't seem to have a need to extend any class here, do we?
+ 1
enum class eNationality
{
Indonesian,
Indian,
// more follows
};
enum class eReligion
{
Buddhist,
Christian,
// more follows
};
emum class eMaritalStatus
{
Single,
Married,
Divorced,
// more follows
};
enum class eBloodType
{
A,
B,
O,
AB
};
class clsCitizen
{
string strID;
eNationality enmNationality;
string strName;
string strLastName;
string strPlaceOfBirth;
string strDateOfBirth;
eReligion enmReligion;
string strOccupation;
enmclsGender enmGender;
string strAddress;
eBloodGroup enmBloodGroup;
eMaritalStatus enmMaritalStatus;
};
enum class eMemberRole
{
Father,
Mother,
Children,
GrandFather,
GrandMother
};
class clsMember
{
string strCitizenID;
eMemberRole enmRole;
};
enum class eIssuer
{
Mumbai,
NewDelhi,
// more follows
};
class clsFamily
{
string ID;
eIssuer enmIssuer;
string strZipCode;
vector<clsMember> vecMembers;
};
+ 1
Ipang true I also don't find need to inherit and your example class looks better.
I only wander is for usage of these classes. Say for example, object for clsMember is constructed but it has only citizen id... What if someone has not created object for same citizen id using class citizens... This only made me think to go with inheritance as it forces to initialize all members.... Still not sure which option is best one or I would say more realistic .
And one more doubt I have is member role. One member has one enm data of role but in reality, father is husband and son of grandparents also. How to store all this ? And again comes maternal parents as well.
Thanks a lot for your time and extended hand of support. Many thanks....
+ 1
Ketan,
I'm not sure what to suggest about data integrity in OOP (2nd paragraph). As I mentioned early on, it is a built-in feature in DBMS, but it's not available in OOP. As we both understood, inheritance is about introducing something new by extending a class, not about data integrity (ensure a valid reference).
About family member role, that is how I interpret the data from my family card. A member's role defines the relationship of the said member to the head of the family, not to its siblings(brothers/sister), or parents of the head of family (grand father/mother).
+ 1
Thanks Ipang
0
Sorry bro, I didn't get the "data distribution among different classes" part. Can you explain me?