Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Entity Relationship Diagram (ERD) : Database Data Type

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

A primary key is a unique identifier for a 

database record. When a table is created, one of the fields is


typically assigned as the primary key. While the primary key is often a number, it may also be a text
field or other data type. For example, if a database contains definitions of computer terms, it would
make sense that each term is only listed once in the database. By defining the "Term" field as the
primary key, it would ensure that no term is listed more than once in the database.

The primary key also acts as a pointer to the record and provides a simple way for the DBMS to
search, sort, and access the records.

It also helps relate records across multiple tables. Therefore, while multiple fields within a table can
be defined as "Unique," each table can only have one primary key.

The primary key field must also be defined for each record and not set to null. After all, a undefined
identifier is not very useful.

There Are Three Types Of Primary Keys. 

You can define a primary key by one or more fields.

In addition to single-field and multi-field primary keys, you also can define AutoNumber
primary keys.

An AutoNumber field automatically enters a sequential number whenever someone adds a new
record to a table.

Or you can create single- and multi-field primary keys. For a single-field primary key, open the
table in Design View. Click the row selector for the field that you want to serve as a primary key.
The row selector is the small button to the left of the row. Next, click the Primary Key button on
the toolbar. Create a multi-field primary key like a multi-field index, but select Yes For Primary
in the lower portion of the Indexes dialog.

The last one is to create an AutoNumber primary key. Enter the table in Design View. After
inserting a row and naming the new field, select AutoNumber in the Data Type column. Save the
table to add your AutoNumber primary key to the table.

Entity Relationship Diagram(ERD)


An entity-relationship diagram is a data modeling technique that creates a graphical
representation of the entities, and the relationships between entities, within an
information system.

 The three main components of an ERD:


 The entity is a person, object, place or event for which data is collected. For
example, if you consider the information system for a business, entities would
include not only customers, but the customer's address, and orders as well. The
entity is represented by a rectangle and labelled with a singular noun.
 The relationship is the interaction between the entities. In the example above, the
customer places an order, so the word "places" defines the relationship between
that instance of a customer and the order or orders that they place. A relationship
may be represented by a diamond shape, or more simply, by the line connecting
the entities. In either case, verbs are used to label the relationships.
 The cardinality defines the relationship between the entities in terms of numbers.
An entity may be optional: for example, a sales rep could have no customers or
could have one or many customers; or mandatory: for example, there must be at
least one product listed in an order. There are several different types of cardinality
notation; crow's foot notation, used here, is a common one. In crow's foot notation,
a single bar indicates one, a double bar indicates one and only one (for example, a
single instance of a product can only be stored in one warehouse),
a circle indicates zero, and a crow's foot indicates many. The three main cardinal
relationships are: one-to-one, expressed as 1:1; one-to-many, expressed as 1:M;
and many-to-many, expressed as M:N.

The steps involved in creating an ERD:

 Identify the entities.


 Determine all significant interactions.
 Analyze the nature of the interactions.
 Draw the ERD.
The building blocks: entities, relationships, and attributes

Two related entities

An entity with an attribute

A relationship with an attribute

Primary key

RELATIONSHIPS IN MS.ACCESS
The true power of relational databases lies in their ability to track relationships (hence
the name!) between data elements.
The different types of relationships are:

 One-to-one relationships occur when there is exactly one record in Table A that


corresponds to exactly one record in Table B.
 One-to-many relationships occur when each record in Table A may have many
linked records in Table B but each record in Table B may have only one
corresponding record in Table A.
 Many-to-many relationships occur when each record in Table A may have
many linked records in Table B and vice-versa.
Queries
Queries are the primary mechanism for retrieving information from a database and
consist of questions presented to the database in a predefined format. Many database
management systems use the Structured Query Language (SQL) standard query format
to help them retrieve data.
The different types of queries available in Ms Access:
Select Query
The select query is the simplest type of query and because of that, it is also the most
commonly used one in Microsoft Access databases. It can be used to select and display
data from either one table or a series of them depending on what is needed.
In the end, it is the user-determined criteria that tells the database what the selection is
to be based on. After the select query is called, it creates a "virtual" table where the data
can be changed, but at no more than one record at a time.
Action Query
When the action query is called, the database undergoes a specific action depending on
what was specified in the query itself. This can include such things as creating new
tables, deleting rows from existing ones and updating records or creating entirely new
ones.
Action queries are very popular in data management because they allow for many
records to be changed at one time instead of only single records like in a select query.
Four kinds of action queries are:
1. Append Query – takes the set results of a query and "appends" (or adds) them to
an existing table.
2. Delete Query – deletes all records in an underlying table from the set results of a
query.
3. Make Table Query – as the name suggests, it creates a table based on the set
results of a query.
4. Update Query – allows for one or more field in your table to be updated.
Parameter Query
In Microsoft Access, a parameter query works with other types of queries to get
whatever results you are after. This is because, when using this type of query, you are
able to pass a parameter to a different query, such as an action or a select query. It can
either be a value or a condition and will essentially tell the other query specifically what
you want it to do.
It is often chosen because it allows for a dialog box where the end user can enter
whatever parameter value they wish each time the query is run. The parameter query is
just a modified select query.
Aggregate Query
A special type of query is known as an aggregate query. It can work on other queries
(such as selection, action or parameter) just like the parameter query does, but instead
of passing a parameter to another query it totals up the items by selected groups.
It essentially creates a summation of any selected attribute in your table. This can be
further generated into statistical amounts such as averages and standard deviation, just
to name a couple.
The SQL aggregate functions available to Microsoft Access are:
 Sum
 Avg
 Min
 Max
 First
 Last
 Group By
 Count
 StDev
 Var
 Expression
 Where
Note - Queries don’t actually run while you are in datasheet mode, because it is
essentially a preview of the application.

You might also like