Question:
what is a relational database?
shhusan
2009-04-25 00:08:00 UTC
HI, I am a little confused as to what a relational database is, all I know is that it uses tables, one for each entity. If a database is a relational database does this effect whether foreign keys are used or not?

Thanks
Four answers:
TorxBit
2009-04-25 00:19:34 UTC
A relations database or RDBMS is a system of tables that contain data that reference each other. And example of this relation can be seen here:

http://en.wikipedia.org/wiki/Relational_model



The idea of keys and foreign keys are part of that model. A key is a column from a table that references that data. It is used to link two tables together and needs to be unique.. A foreign key is a set of one or more columns in any table (not necessarily a candidate key, let alone the primary key, of that table) which may hold the value(s) found in the primary key column(s) of some other table,

http://en.wikipedia.org/wiki/Foreign_key
anonymous
2009-04-25 00:53:33 UTC
A relational database uses tables for minimal amounts of information. So as you say there would be an entity for people maybe called individuals and then a table for transactions, along with possibly companies, company addresses called co_address, home addresses called ho_address and so on.

What makes it relational is that you can set up relationships between the tables.

So with :

individuals : id int() primary key auto_increment, last_name and firstname both of varchar(), then maybe a birthdate as an extra identiifier, and these last three would be a unique key to prevent duplicate entries

Often an account number would be the idnividual ID



transactions : id int() auto_increment, description unique key



companies : id int() primary key auto_increment, name varchar() unique key



co_address : an int() primary and all the address fields



ho_address : same as above



you would also have an indiv_address table which was simply 2 fields, a list of individual_id against ho_address_id, then a comp_address with companies_id against co_address_id

This way a person can be linked to more than one address, allowing for people with multiple homes. One major company can have hundreds of links against their site addresses. Each described transaction would be a description (maybe sales) and an ID, but might include a field to hold the id form a void transaction with links it to a table of reasons for voiding and void date.

A transaction link table would include the transaction_id, the indiv_id and a date, with a primary key of id which would be int() auto_increment type and a date.

Each transaction could be looked up against the person, the date and the ID of the resulting transaction can then look up the sale cost, the quantity and a partcode.

These links form the relationship, nothing to do with how it is displayed or grouped. There is not even a need to use foreign keys as such, when you write a query it can include linking a company to a site address and this makes the site address primary key the foreign key from the companies table.

This way no record ever leaves you in a difficult situation when something changes. An individual could change their name as in marrying and you simply change it once in the individual table, a price may change in a stock table and would reflect all pending transactions, but all previous transactions would be linked to an invoice parts table which is again linked or relates to invoices.

Very complicated to keep track of when setting it up, very easy to create queries or groups of queries which will ALWAYS return consistent results. One change reflects in results from all the tables.
?
2016-10-25 13:25:49 UTC
it actual relies upon on the equipment you want the database for, even if you're keen to spend slightly bit time growing your database (rational one) or decide on some thing quick, even if you decide on some thing useful (relational) or you're keen to settle (flat record). A flat record is largely because the time period shows a record containing in straightforward words one table. All products of information are kept in a unmarried table, rendering information retrieval complicated and chaotic. also compared to in relational databases, doubles are immediately further as the different get entry to may, making it no longer a danger to understand which one's the right ideal get entry to. E.g. enable's say there replaced into an get entry to about John Smith (Social protection huge form XXXXXXXX, one of those piece of information is termed a first key) which pronounced he's 40. next somebody else or you your self attempt to operate a sparkling get entry to, similar data except for the age, enable's make it 50 this time. Flat record will shop the files in a snap without questioning two times, a rational database will ask you what to do with the files on the grounds that 2 entries can not have a similar favourite key, so that you're gonna might want to drop between both.
Nahee_Enterprises
2009-04-25 00:11:46 UTC
A relational database is a database that groups data using common attributes found in the data set. The resulting "clumps" of organized data are much easier for people to understand.



For example, a data set containing all the real estate transactions in a town can be grouped by the year the transaction occurred; or it can be grouped by the sale price of the transaction; or it can be grouped by the buyer's last name; and so on.



Each "table" contains only those "fields" which are related to each other.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...