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
0
votes
1 answer

Doctrine : One to one to one relation?

I'm making entities for a Symfony2 project at work. I'm trying to make a system that controls the access to certain resources in function of an organisation (a company) and of a role. To sum it up, roles are the same for all the companies, but a…
Gabriel Theron
  • 1,346
  • 3
  • 20
  • 49
0
votes
1 answer

Updating an existing entry in my database isn't working

I'm trying to use a list of clients that have been created from my client model in my new model called Jobs. Basically. A user should be able to view a list of jobs that are currently assigned to any one client and then drill down into further…
-1
votes
1 answer

Unable to determine the relationship represented by navigation 'Customer.BoughtProducts' of type 'ICollection'

I have 3 models and a User class which defines the common properties for customer and seller so I won't attach it (I guess it would be useless info). public class Seller : User { public bool IsApproved { get; set; } public…
-1
votes
1 answer

Best way to handle this relation in Room Database

I have three tables and I have a many to many relationship here: Contact table: @Entity(tableName = "T_Contacts") class Contact( @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "_id") var id: Long, @ColumnInfo(name = "phoneNumber") var…
Kristy Welsh
  • 7,828
  • 12
  • 64
  • 106
-1
votes
1 answer

Show relations between tables in SQL+(Oracle)?

What is the query to show relations between existing tables in SQL+ (Oracle)?
-1
votes
2 answers

Resolve the database relationship cycle

In the database I have a model of kind: The customer can either rent a car or rent out a car. As you see Car has OwnerID - customer who owns a car but at the same time customer can also rent a car from another owner so that in Order table he…
Storm
  • 557
  • 1
  • 8
  • 25
-1
votes
1 answer

Ruby on Rails - Image has many Tags, activerecord

Using rails 4.0.0 I'm trying to understand what "many to many, many to one, one to many etc" relationship i should use to do the following: Image Table: |file_name|description| test.png test image test2.jpg another test image Tag…
Daniel
  • 3,017
  • 12
  • 44
  • 61
-1
votes
1 answer

How to add relation to "static" table in SQL Server CE

First off all I'm using SQL Server CE and I've created a data context for my database to handle it in C# code. This is my problem: In TableA, there are several "static" items that won't change: they are "attributes" like the…
-1
votes
3 answers

Entity Framework compilation error. Class cannot be used as scalar property, because it does not have a getter and setter

With Code First approach and implementing a database for an existing system. Therefore I cannot make alot of changes to the existing code. That's why I'm using Fluent API and Entity Framework. When I'm trying to implement a new class (Vector) which…
jonas
  • 1,592
  • 3
  • 20
  • 29
-1
votes
1 answer

Doctrine2 Zend many-to-many relationship issue

I have a many to many relationship set up between listings and categories. I am trying to set the categories for a listing using $listing->setCategories($categories). I do not get errors but the relationship isn't saved to the db. I will include all…
-2
votes
1 answer

Vaccination Database design ERD

My intentions to design the database schema for the small pet vaccination application. Inside Pet table I want to store details about the pets and if specific vaccination is required. There are 3-4 vaccination types(VT1, VT2, Vt3, VT4), which is…
-2
votes
1 answer

Creating database in SQL Server (problem with relationships)

I need to create a database from a CiteScore file (the file contains 10 identical pages from different years). I already created it and added tables from this file and assigned a variable ID for the primary key, but I wonder how to create a…
-2
votes
1 answer

PostgreSQL database design for Django real estate website

I'm working on a real estate website, and am struggling to define a design for my DB. Database needs to store Properties, attributes, property category/subcategory, and have them be linked all together. I could easily solve said problem by…
Milos
  • 981
  • 3
  • 16
  • 41
-2
votes
1 answer

Does Relations between tables in database speed up performance of queries?

I am using join in my quires and i want to know if the relations between database tables leads to increase performance of the queries. Thank You.
Ali
  • 1,633
  • 7
  • 35
  • 58
-2
votes
1 answer

I calculate user's rating as a sum of item's numbers the possess, but my way is very slow

I have a table 'users' with usual fields plus 'owned_items' and 'rating' fields and a table 'items' with their id's, and some other properties. User can posses many different items of each type and its rating is calculated by summing up the all…
1 2 3
21
22