How to handle inheritnace with Prisma? - database

is there a way to manage inheritance in prisma ?
I have a table baseUser which contains some basic columns like name, email, password,... I also have a second table which represents a customer and I want it to contain all baseUser columns without duplication. I've tried to set a one-to-one relation but I wondered if there is any other solution like inheritance for instance.
Thanks in advance.

Inheritance is not currently supported in Prisma.
There is an existing issue which describes progress and ideas on how schema.prisma file can support implementing interfaces where multiple models could implement the same interface.
Inheritance GitHub Issue

Related

MeanJS: Generate the Sub-CRUD-Module with the generator?

I have a CRUD-entity with a strong relationship to another entity, like comments only be posted and viewed above an article.
I want to use document db structure. Every comment should be saved in its article. I dont want to have a comments collection in which every comment is saved and referenced from the articles collection, like a relational db structure would suggest.
My question now is: What is the best practice to create a document style sub crud module in MEAN.JS?
Should I...
generate it, disable the creation in the collection and link the angular-controllers/views across the modules?
generate it, disable the creation in the collection and move the files to the father crud module?
refrain from generating it, create all needed files direct in the father module?
Create all needed files direct in the father module.
I did something similar to avoid referencing to other documents, you can edit the module schema to embed a schema into a schema, check this link:
http://www.jonahnisenson.com/schema-within-a-schema-use-embedded-documents-in-mongoosemongo/
You don't have to generate a separate CRUD Module for it. Generate a normal CRUD Module for the Articles and in the server sub-folder, you can create the model of the comments. After creating the Comments Model, You can then create another Model for Articles and then you refer to the Comments Model as part of the Article Model.

In joomla components, where should i store the database functions, and how to call them?

I am now building my first joomla component.
I have 3 tables in it:
__questions
__resaults
__display
I also need the Joomla user table:
__users
I have a single view:
view.questions.html
this view gets data and also needs some database functions. It needs to:
Get information from the user table.
Get information from the resaults table
Get information from the display table
-SET- information to the reaults table
Now, I know Joomla is built with MVC architecture. This, I assume, means no dealing with database in views.
Where should I store the database hendling functions, and how can I call them in the front end?
The function dealing with questions is in the question view model, no problem, but what about the other tables? Should I put the functions dealing with them in the question model as well, the helper file, or make models for each other table, and call them from the question view? If i should make other models, how do I call them from the question view?
Thank you very much for your help!
Create a model for each table.
You will then instantiate them from the controller to make them available to the views.
You can save a lot of time and also learn a lot by using the Component Creator: http://www.notwebdesign.com/joomla-component-creator/ It will do all the MVC stuff for you.

Using liquibase, how to handle an object model that is a subset of database table

Some days I love my dba's, and then there is today...
In a Grails app, we use the database-migration plugin (based on Liquibase) to handle migrations etc.
All works lovely.
I have been informed that there is a set of db administrative meta data that we must support on every table. This information has zero use to the app.
Now, I can easily update my models to accommodate this. But that answer is ugly.
The problem is now at each migration, Liquibase/database-migration plugin, complains about the schema and the model being out of sync.
Is there anyway to tell Liquibase (or GORM) that columns x,y,z are to be ignored?
What I am trying to avoid is changesets like this:
changeSet(author: "cwright (generated)", id: "1333733941347-5") {
dropColumn(columnName: "BUILD_MONTH", tableName: "ASSIGNMENT") }
Which tries to bring the schema back in line with the model. Being able to annotate those columns as not applying to the model would be a good thing.
Sadly, you're probably better off defining your own mapping block and taking control of the Data Mapper (what Hibernate essentially is) yourself at this point. If you need to take control of the way the database-integration plugin handles migrations, you might wanna look at the source or raise an issue on the JIRA. Naively, mapping your columns explicitly in the domain model should allow you to bypass unnecessary columns from the DB.

CoreData migration & data mapping: creating a new entity from existing attribute

I really hope someone will be able to help me out with this.
I am trying to create a data mapping model (for an iOs app) in Xcode for the first time.
This should be a very simple migration (although not covered by lightweight migration); here is what I originally had and what the new database looks like:
What changed:
I have a new attribute (DBdisplayOrder), which is optional
I have a new to-many relationship. I would like to move the old database's DBreminder (NSDate) attribute to the new DBreminderDate. Both attributes in the new table are optional.
So basically I only need to copy data from one attribute, which now resides in a new entity.
I would be very grateful if someone could point me in the right direction, or just recommend a good resource to study from and get started.
I have sold this problem using a great description found here.
Update: (Fixed link to what appears to be the same blog post)
Here is the working mapping model:
I hope it helps someone.
Creating a mapping model can get fairly involved. I would start with the Core Data Model Versioning and Data Migration Programming Guide
In this particular case you will need to create an explicit mapping model, then you will have to create an entity mappings that describes both your original entity and the new target entity you want to move the attribute to. Then create a property mapping for that particular attribute.

Pulling in Dynamic DBF Columns

I have been asked to pull in columns for use in a web app.I am using asp.net and C#. I was using a dataReader to populate the class variables. The problem is that the dbf file can change. Sometimes rows are added or deleted so my class would have to change every time the data source file changes to represent the columns Is there a way around this?
Lots of ways of addressing this issue, your problem is handled by a whole class of solutions known as Object Relational Mapping or ORM. The absolute king of these in the Java and .Net world is NHibernate. This does nean a rebuild with each DB change though, I use code generation to solve that problem, builds the class and mapping files direct from the DB. Then you get into TDD and CI, to make sure you haven't broken anything and then .....
However, if you want something quick and dirty you could create a dictionary within your classes and store any extra columns in there. Completely flexible but your classes extra columns aren't defined within the class itself.
I just used a few try/catch blocks to solve this.

Resources