Skip to main content

Questions tagged [relations]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
14 views

Summing values from different tables in access

I have 3 tables, student table stores information about students, Fee table stores information on fees paid by students and Collections table stores information on what a student has paid for which is ...
0 votes
1 answer
660 views

Table Relationships for Property Bags Configuration

I am creating a database table setup for user preferences in my application based partially on this design and while I created the tables and foreign keys, I can't seem to figure out the relationships ...
1 vote
1 answer
991 views

ER Diagram | Group, Post, User relationship

I need to design an ER diagram, but I am confused in a section, more specifically how to relate the post with the groups, because I need that post contains the information of in which group I publish ...
0 votes
2 answers
5k views

System/database design for comments/replies and upvotes at scale

Recently I started discovering a topic around "How to design db schema for storing structures similar to Instagram/Facebook/Reddit comments?". After extensive research, I was able to find a ...
2 votes
1 answer
457 views

Modeling an either/or relationship

I've seen this post (How should I model an “either/or” relationship?) but it's not exactly what I'm looking for. both answers are suggesting creating a subtype instead of a relationship. Say I have an ...
2 votes
0 answers
22 views

Is there an algorithmic way to identify potential primary key foreign key relationships in postgres

I have a lots of tables in postgres with a lots of columns per each table. I need to write a program in such a way that it can identify the columns that can be a potential primary and foreign key pair....
0 votes
1 answer
35 views

Possible options for SQL and NoSQL combination for social media data

I have searched this forum for an answer but could not find anything relevant. We are designing database schemas for a social media app with posts, groups, users and chats etc and it looks like we ...
1 vote
1 answer
66 views

How can I SELECT columns from one table that corresponds with a column of another table on JOIN without creating a relation between the tables?

I have 3 tables: CREATE TABLE catalog.shoes ( shoe_id SERIAL PRIMARY KEY, brand VARCHAR(255) NOT NULL, model VARCHAR(255) NOT NULL, price INT NOT NULL, CONSTRAINT shoe_name UNIQUE (...
-1 votes
3 answers
425 views

Given a table containing class and students, need to find the diff in students

I have class_students table where given 2 class ids I need to find the diff in students. This is sql fiddle that I used, http://sqlfiddle.com/#!9/dba48e/11 Any help here.
0 votes
0 answers
33 views

Noobie needs help on designing database for membership management tool

I have searched through some of the database examples, but have yet to wrap my head around the logic of the relations between databases, so appreciate some support. Here is what I am trying to do: for ...
0 votes
1 answer
289 views

What is the most straightforward way to create subtypes and supertypes at the same time?

I hope this isn't too basic a question, but I am hoping that the DB engineers here will help me out. Do relational DBs usually have a straightforward way of doing the following?: Create a supertable ...
0 votes
2 answers
209 views

How to join multiple many to many tables

I have tables - games, game_views, game_views_game_links, genres, games_genres_links. I need to count views from game_views, filter by them and join genres table to genres field. If i use only 2 joins ...
-1 votes
1 answer
2k views

Update all rows with a one to many relationship count in the same table in MYSQL

I am trying to update all rows of a MYSQL table with the total amount of referred users for each user. 1 user can refer multiple users and I need to run a MYSQL query to update the invite count (total ...
3 votes
1 answer
213 views

How to "merge" rows along with their foreign many-to-many relations without violating unique constraints?

Fiddle: https://dbfiddle.uk/-JLFuIrN Table CREATE TABLE files ( id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text ); CREATE TABLE folders ( id bigint GENERATED ALWAYS AS IDENTITY ...
1 vote
1 answer
269 views

How to count the number of relationships to a table in MySQL?

I am arranging an ERD diagram of an existing database with about a 100 tables, to add some structure to the process, how rank out the number of relations the tables have to each other? For example, ...
0 votes
1 answer
87 views

Store different data of the same format in one table, or multiple tables of the same format?

Consider I have the following MySQL tables: products id | created_at | updated_at | name | description | barcode stores id | created_at | updated_at | name | description | address product_attributes ...
0 votes
1 answer
52 views

How can I transform an exclusive constraint relationship from ER to RM model?

Let say we have two entities TEACHER and COURSE. There are two relationships between them. A TEACHER can teaches a COURSE, and also can learn a COURSE, however, the TEACHER cannot teach and learn a ...
0 votes
0 answers
269 views

Create a student-grade query from a relational database

I have three tables: Students (Id, name) Assessments (id, name, max_score) StudentAssessment (Id, student_ID, assessment_id, score) where ids are FK from the other two tables. I think this is the most ...
2 votes
0 answers
204 views

My relational schema and a few questions about relations and duplicate values in columns

I'm trying to create database in which I could store thousands of job postings. I put here 5 sample records of these job postings so that you could better understand how everything looks like: Now, ...
0 votes
1 answer
228 views

Should I use JSON or related tables to represent a relation in Cassandra?

I know it is possible to store JSON in Cassandra, and I also know that Cassandra is a structured query language. Because of these two informations, I am unable to determine whether I should store some ...
2 votes
3 answers
567 views

Database Design - Relationship between two or more junctions tables

I am a junior developer and I don't know how to implement this next relationship. Note: All entities described here are fictional but have equivalents in an actual production Database. Performance is ...
0 votes
1 answer
293 views

How to automaticaly create entries in a parent table before filling child table? What is that called in db terminology?

What I want is for inserting the string name of a publication in a child table to associate with the PK of the publication in the publications table. For example, let's say I have a table of counties ...
0 votes
0 answers
115 views

Designing one to many relation where Many can be one of 2 entities

Apologies if this seems like a rather naive question but I'm relatively new to database design and I'm struggling to find the correct terminology to help source answers myself, so I'm turning here. ...
1 vote
1 answer
83 views

Terminology for Specific Kind of One-to-Many Relationship

This question regards how a one-to-many row might "belong" to a different row and what exactly to call it. I might be asking for a term that does not exist. Please see the below two tables. ...
0 votes
1 answer
124 views

How to create a reference in a many-to-many relationship with transact SQL?

I am creating my first database using only code (I don't like to use graphical interfaces, I feel that I am not learning to write T-SQL code, it is my personal opinion), I do not know how to create ...
0 votes
0 answers
46 views

Should I create a linking table between two tables with existing IDs or add a column to an existing table

So I have two tables. Not with these exact columns but it's just to illustrate the point users id | forename | surname forms id | name Using MS SQL and was wondering what's best practice to link a ...
1 vote
1 answer
1k views

referencing data from another table without using a join

Hi all so I have a homework assignment that I am having difficulty understanding. the problem I have been given is this: ix. Referring to the customers and shipping_details tables on the ER, ...
2 votes
2 answers
316 views

foreign key table update impact

Lets say there is orders table with few foreign keys. One of them is addressId. Orders -- Id -- orderNum -- customerId -- addressId (foreign) CustomerAddress -- Id -- customerId -- street -- cityId --...
1 vote
1 answer
17 views

Creating relations that makes sense in a many 2 many 2 many format or is the solution badly designed?

I'm trying to get better at databases and started a hobby project for this. So this is the flow I'm trying to achieve. A user can have one or more portfolio A portfolio belongs to that user A ...
0 votes
1 answer
19 views

Convert generalization in ERD to Relationnal Database having no additional column

I've a quite simple problem but the litterature I came accross didn't seem to dwell on. Let's say I have an entity OFFER which represents an Offer on a Product, for each product, one offer can be &...
1 vote
1 answer
48 views

Database Design for evolving entities

I am looking for some best practices regarding table design when an entity is expected to evolve over time and get more properties. As an example let's consider a process that has a bunch of metadata ...
1 vote
0 answers
72 views

How to restrict allowed sub-entities in table referencing super-entity based on a type code

I'm working on my first db architecture for a platform containing several user types and that can exchange assets between them. There are also several transaction types, but each transaction type ...
0 votes
1 answer
129 views

What database & design would you use for legos [closed]

I'm trying to conceptualize an interesting problem I am designing for. Using lego's (the plastic construction toys) as an analogy seems to work well. If this is a fairly recognizable problem, then I'd ...
0 votes
3 answers
63 views

Best Practice to define has many through relationship

Given the Images. Sometimes I needed to fetch lessons related to a course without joining the topic table. It is a good way to model the Schema in the diagram at the bottom? Kindly advice.
0 votes
1 answer
2k views

How return list with inner list in SQL? [duplicate]

I prepared following SQL statement: SELECT tasks.name, profiles.email, types.specification, tasks.description, tasks.attachment_link, tasks.priority, assigned_tasks.progress_details, ...
-3 votes
2 answers
73 views

Postgres relationship statement [closed]

Lets say I have the table parents. A parent has many kids and a kid has many toys What would be the best way to do a SELECT statement for the parent and grab all of kids associated with that parent ...
0 votes
1 answer
103 views

MS SQL DB design help

I'm stuck with table design and query FOR XML Sync engine for Ads requires XML schema in this format <attribute1>value</attribute1> <attribute2>value</attribute2>… <...
1 vote
1 answer
413 views

ER Schema - bank system

Hello i'm trying to model a simple banking scheme where I have 3 transactions: withdraw, transfer, deposit. of these 3 operations, the transfer is the only one that needs more attributes, I need to ...
1 vote
1 answer
89 views

Many-many relation with specific type

Sorry if this question has already been asked, but I didn't find it performing a search. I have 2 tables (table_a and table_b), linked by a many/many relation. The relation can be of two types, ...
2 votes
1 answer
4k views

Is it good practice to create a separate table for views count?

I have created a blog table where I'm having a field called views_count but I have heard that updating the views_count field on each page view is strain. So I have created now a seperate table for ...
0 votes
1 answer
74 views

Cardinality between tables in the present or over time?

I have a question regarding cardinality between two tables. I'm not sure how to approach it. Imagine the following: There are groups: group 1, group 2, group 3 etc One group can have multiple items ...
1 vote
1 answer
42 views

Need a better approach in how to design this relation

I have a table fluxo, and fluxo have many fluxo_acao, but a entry in fluxo_acao can have three types, and each type have they particularities. to acomplish this, i created more three tables(...
1 vote
1 answer
290 views

Relationship design for areas, managers and general manager

Given some specifications I need to design a database for an organization. One of the parts has to do with areas. In the organization there are different areas, each area has a boss, and there is also ...
1 vote
2 answers
872 views

database management system vs database vs tables vs file [duplicate]

I have been trying to understand the way a database system works. Digging through the internet, I have come to following picture. Database system is required because we need a way to store data, ...
0 votes
1 answer
686 views

Whats the right table relationship for these entities?

I want to store all the data for the following entities: Users Projects Roles A user can work in multiple projects and can have many roles, but only one role for a user should be allowed in each ...
0 votes
1 answer
170 views

What are the main disadvantages of adding relationship between tables at later date?

During early development I tend to create tables using running numbers as Primary Key, although there is formally a real ID column for each table. I tend to forget mapping the relationship between ...
0 votes
2 answers
66 views

Is there a good reason to create an additional table to realize a 1:N relation?

I have the following tables: Users _____ UserID Data ... Roles _____ RoleID Data ... UsersRoles _____ UserID RoleID Users and Roles are in a M:N relationship. As such I have the UsersRoles table to ...
1 vote
1 answer
432 views

Should pivot tables have more columns (many to many relationship)

I'm currently thinking about how to organize my tables, and I have some information that I'm not sure were should be, one of them is the quantity of a food in a refrigerator Is it right if I add ...
1 vote
1 answer
297 views

Understanding linking tables in a many-to-many relationship

I am still working on a photo storage app (designing the database for the data for the photos stored), using MySQL, and have been told that a photo may have one or more people in it, and a person may ...
1 vote
1 answer
87 views

Should I capture all the relationships in a Database design?

I am a newbie when it comes to database design. I was trying to create a blogging application and I ran into a problem. My database consists of the following tables: User HasInt (Records which user ...