Dio Phung
Dio Phung

Reputation: 6272

How to design NoSQL database to represent inheritance?

How would I design my NoSQL database (MongoDB) to represent this hierarchy ?

public abstract class Customer {
  Guid Id;
  String Name;
  Decimal Balance;
}

public class VipCustomer: Customer {
  String Address;
  String PhoneNumber;      
}

public class NonVipCustomer: Customer {
  String VisitingReason;
  Int QueueNumber;
}

Upvotes: 1

Views: 735

Answers (1)

dwaz
dwaz

Reputation: 664

Are you using a Object Data Mapper like Mongoose to manage your schemas? If so, you might try this extension from GitHub to handle inheritance:

https://github.com/briankircho/mongoose-schema-extend

Upvotes: 1

Related Questions