CREATE POSTGRESQL Entity Relationship Model - postgresql

I desperately need your help. I have database tables IN POSTGRESQL which I need to create an ER Model for them. My challenge is creating relationships among the tables. I know this might be alot of work but I just need help on creating relationships among the tables, what column names should I use and all that . Here is an image of the tables in the database

Related

Is it necessary to define entity file of the table if table already exists in typeorm(btw I am using postgres if it matters)?

If it is not necessary can anyone tell me the way? because I want to test a Typeorm query which actually has a lot of tables connected to it? defining all the tables will take a lot of time?

laravel model best practice

Hi I'm using laravel in my current project. I thought its recommended to create a model for each database table to get the best out of eloquent's Relationships
somewhere in my Database I have this mapping table to map records from table A to table B (many to many)
should I create a model for my mapping table ? what is the best practice in such cases?
This question is best answered from an architetural point of view:
Models are made to represent entities. Mapping Tables do not store entities but information about relationships between entitites (many-to-many). Therefore, creating models for mapping tables does not make much sense.
Laravel offers a concepts called pivot-table for this kind of usecase, which is very well documented in the docs.

Way to get all relations and tables between tables

I am working about a very hudge PostgreSQL database.
The database have more hundred relations between table. But I want to link two tables named "client" and "services" (in order to quering these tables) but I don't know what relations take to link them.
I can't install tools to do this. I can only use the command-line interface.
Are there a way to do that ?
EDIT : This question is not duplicate because I never ask the relation presents in a table.
I want a way to map (get all tables) between two tables. These two tables don't have a common relation because they are distant from many tables in the database.

Map multiple tables to a single entity dynamically

I have some tables which should add to my database every year and name of databases contains the year (like sell2005) and iv'e written some ef queries on these tables ,and queries can only be on a single entity (like sell2005) but what should i do when sell2006 or sell2007 add ? how can i manage them with that single query which iv'e written before?
thank you.
There is no easy way. EF is simply not tool for this scenario. For EF you must have "single table" so you must either use partitioning with one real database table partitioned by year or you must build a view on top of these tables.
The problem is that in EF you have strict relation between classes and tables. You cannot have single class mapped to multiple tables even if they are exactly same (except inheritance which is not solution for you). So the workaround would require to have multiple SSDL/MSL mappings - one for each table and construct correct context instance with correct mapping for every query. As I know dynamic changes of mapping are not possible (except modifying SSDL/MSL files before using them).

one or more Entity models for one database for entity framework?

When use entity framework for DAL tier, VS 2010 can create edmx for each database.
Question:
If I have a database with many tables, should I create only one edmx for all tables or mutiple edmx files? for example, maybe all security tables for one edmx file, other tables for another edmx file. If there is more than one, then in other tiers, there will have more then on ObjectContext in code for business logic.
Which one it the best solution for this case?
I've done this before when experimenting with AdventureWorks. If you have a large database with lots of tables, and the tables are segmented into separate schemas (like the Purchasing, Sales, HumanResources schemas in AdventureWorks) then it may work well to create multiple models. They don't have to be separate schemas- any two groups of related tables where there are no relations between the groups would work.
You'd want to make sure that you include all related tables in each model so that you don't have to try to join entities across models.