Posty

Wyświetlam posty z etykietą Postgres

Two entities coexisting in one table

Obraz
I have stumbled across small problem. I had an abstract class, which aggregated all mutual properties of an object and two concrete classes. One did not need any additional fields, while the other needed another relation. Idea was to create one table and gather both those concrete objects from it. I have never done it before, so it was interesting thing to discover. I was working on Team abstraction. Team is a collection of heroes. But teams can be lead by someone or self-organized, hence I have three classes, like so: Notes: BaseTeam is an abstract class annotated with @MappedSuperclass . Since it is abstract I cannot instantiate it and with annotation all its properties will be passed to class extending it. Team class is a concrete class extending BaseTeam. It inherits all the properties from its superclass and does not define any new. It is annotated with @Entity and @Table with filled name property.  It is important to fill those properties, so concrete class can re...

Project: Simple filesystem

Obraz
Introduction Music: Some random YouTube suggestion ,  Barns Courtney - Fire , Taco Hemingway - Grubo-chude psy Repository: https://github.com/KKucharczyk/Filesystem Resource management is all around us. On macro scale, the sand is just a resource. Resource we, people are constantly using in construction industry. Food is a resource we are dealing with every day. Amount of wheat in given country is also a resource. And resources usually needs to be managed. As a programmer, I tend to meet resource management also, on a smaller, micro scale. My Ubuntu operating system with its shell allows me to organize my files. My applications are constantly using some resources of my computer's or servers' they are working on, which I try to optimize. Databases are working on huge sets of data and it's my job to predict and handle situation, when requested resource is available or does not exist. Managing assets is a common thing in projects. I have worked in the past ...

Messing with PostgreSQL: b-tree indexes, likes and operator classes

I can do a lot with JPA. Working with database is not a hard thing in Java environment. Java EE has a pretty easy standard when it comes to working with data, Spring makes configuration even easier and Hibernate takes care of almost every problem with already created and tested solutions. Although lately I started to peek at the possible optimization. Since I have came to as little Entity Manager calls as possible, there is not much to do in the code. So I decided it is, finally, time to dive deeper into databases and their magic world of indexes, analyzing, likes, trigrams, etc. I am used to work with PostgreSQL RDMS, so this post will be mostly in its dialect. What I already knew? If you want your database to work faster - index its appopriate fields. Basic knowledge. But... why? How does the indexing work? Those are my new questions. And to get some answers, since lately I started to work with Spring Boot (literally just searched to see, how correctly write it :o ) and Sprin...