Questions tagged [database-relations]

A relation is a data structure which consists of a heading and an unordered set of tuples which share the same type.

A relation is a data structure which consists of a heading and an unordered set of tuples which share the same type.

When Edgar F. Codd invented the relational model, he generalized the concept of binary relation (mathematical relation) to n-ary relation. Relation is a fundamental concept in relational model.

  • A relation has zero or more tuples.
  • A relation value is an instance of a relation.
  • A relation variable (relvar) is a variable which has a relation value.

In some contexts, relation means relation variable. In other contexts, relation means relation value.

In SQL, a database language for relational databases, a relation variable is called a table. Relational model concepts including relation

A relation value, which is assigned to a certain relation variable, is time-varying. By using a Data Definition Language (DDL), it is able to define relation variables.

  • A heading is the unordered set of certain attributes (columns). A heading has zero or more attributes.
  • A body is the unordered set of tuples, which constitutes a relation value. In other words, a relation value consists of a heading and a body.
  • A tuple is a data structure which consists of the unordered set of zero or more attributes.
  • An attribute (column) is a pair of its attribute name and domain name. Domain can be considered data type, or simply, type.
  • An attribute has an attribute value which conforms to its domain. An attribute value is a scalar value or a more complex structured value.
  • The degree of a relation is the number of attributes which constitute a heading. The degree of a relation value is zero or more integer. An n-ary relation is a relation value in which its degree is n.
  • The cardinality of a relation is the number of tuples which constitutes a relation value. The cardinality of a relation value is zero or more integer.

There are no duplicate tuples in a relation value. A candidate key is a certain minimal set of one or more attributes that can uniquely identify individual tuples in a relation value.

319 questions
1
vote
1 answer

StrongLoop loopback - how to exclude results without related model results

I'm using this Node API JSON, which returns Customers, their instances, and the instance versions. Customers.find({ "include": { "relation": "instances", "scope": { "include": { "relation":…
dave-o
  • 47
  • 5
1
vote
2 answers

How to get Hibernate object relations dynamically?

I'm using Hibernate and I need to find a way of retrieving the relations for an object dynamically at run-time. I can't find this in the API. Can anyone point me in the right direction?
Michael Jones
  • 115
  • 2
  • 9
1
vote
1 answer

Loopback Model Relations not saving properly?

PATIENT MODEL { "name": "Patient", "base": "PersistedModel", "idInjection": true, "properties": { "createdDate": { "type": "date" } }, "validations": [], "relations": { "profile": { "type": "hasOne", …
1
vote
1 answer

Should I change/normalize my ER (1:1) diagram?

I made an ER of my table, im not sure if its correct. In my table (0NF) are 5 columns: DocumentID, DocumentTitel, revNr., userID, modifiedDate. The table gives an overview which person changed which document. My data…
1
vote
1 answer

How to Create a 3 Column Join Table Between 2 Models

I'm trying to create a join table between 2 models that has 3 columns. The models are called User and Dare. The join table is called DaresUsers. And what I want to include in the join table is an author_id, accepter_id, dare_id. Each dare will only…
ddig
  • 13
  • 3
1
vote
1 answer

database design for a symptom checker application

I am trying to create a symptom checker similar to WebMD where user inputs their symptoms and based on the input it suggests the disease. I have two tables, one containing all the symptoms and the other containing all the diseases. But I have no…
1
vote
1 answer

How to visualize relation between objects in a database?

I have a database which I want to visualize in some kind of tool. Let me explain the basic: Company A does business with Transport Company A and Transport Company B. Transport Company A does business with Company A, Company B and Company C. Company…
1
vote
2 answers

Too many results on a double join

I got 3 tables that i need to get data from: RECIPE - id, name, worktime, date, describtion TAGS - id, name INGREDIENT - id, name, created Now, both tags and ingredient has a many-to-many relation with recipe. When i try to query my DB to…
Rasmus
  • 177
  • 9
1
vote
0 answers

How to use DataSet Relations with several different relational types to the same child table

I´m trying to dynamic load a DataSet with hierarchic multilevel related tables. There is no problem as long as I have relationships with unique tables, but when the same table exists in several different Relations, I get trouble with that ds.Tables…
jensa4ever
  • 11
  • 4
1
vote
2 answers

Implementing complex references without a trigger in PostgreSQL

I am creating a PostgreSQL database: Country - Province - City. A city must belong to a country and can belong to a province. A province must belong to a country. A city can be capital of a country: CREATE TABLE country ( id serial NOT NULL…
Manolis
  • 192
  • 1
  • 12
1
vote
1 answer

How to see how many relations a Django model has in admin?

I would like to display how many relations an object has in the Django admin. Let's say I have the following models: class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date…
IPDGino
  • 706
  • 1
  • 8
  • 17
1
vote
3 answers

PHP / MySQL relation between 2 tables

I am using the following tables: artists related_artists The idea is when I enter an artist's page with an artist_id I can use that id to load related artists. The following code works, but how do I put it in a single query? I can't figure it…
Fabian
  • 107
  • 2
  • 2
  • 9
1
vote
1 answer

How do I get multiple relationships working properly?

Currently, I can pull out all of the products from the items table, but I cannot match the sizes_id up as the relationship between is set in SizesToProducts table. Database tables are as follows: Items (id, product_id,quantity) Products…
1
vote
1 answer

Determining what's on a Many to Many relationship

This is probably a simple answer, but I've been working on this problem, for the past couple days, and it's starting to drive me batty I have a database with a many to many relationship ------------- --------------------- …
1
vote
2 answers

How to get the tag relations results just by using SQL(s)?

Table tags: article_id tag 1 Language 1 Java 1 c++ 2 Language 2 c++ 3 c++ and how can I write SQL(s) query(s) to make the data like below: Table tags_relations: tag1…
Shuoling Liu
  • 491
  • 6
  • 19