Relational Data Model-1-23
Relational Data Model-1-23
Each column of a table is associate with a Column Names Column Data Type
data type. StdID CHAR(8)
Data Type: defines a set of values and StdFirstname VARCHAR(50)
permissible operations on the values. StdLastName VARCHAR(50)
Constraints that are directly applied in the schemas of the data model, by
specifying them in the DDL (Data Definition Language).
Constraints on Relational Database
NULL value: a special value that represents the absence of an actual value. A null
value can mean that the actual value is unknown or does not apply to the given
row
Primary key: a special designed candidate key. The primary key for a table cannot
contain null values.
• can identify the row in the relation (table) uniquely
Entity integrity rules: No two rows of a table can contain the same value for the
primary key and no row can contain a NULL value for any columns of a primary key.
Entity Constraints are also referred to as Key constraints
Integrity Rules
Enrollment Table
OfferNo StdID EnrGrade
20191000 EM2000 6
20191001 MI2000 7
20191001 MI3090 5
Integrity Rules
Connection among Tables: Relationship connection between rows in two tables.
Relationships are shown by column values in one table that match column values
in another table.
Referential integrity means that the values of columns in one table (the child table)
must match the values of columns in other tables (the parent table)
Foreign key: a column or combination of columns in which the values must match
those of a candidate key. A foreign key must have the same data type as its
associated candidate key.
• Only two kinds of values can be stored in a foreign key:
A value matching a candidate key value in some row of the table containing the associated
candidate key
Or a null value
Questions and Problems
Define fields (which is also known as column headings). Each field must have a
unique name, and data type (may have other constraints in addition)
• Adding Field Names in Table Design View
• Assigning Data Types in Table Design View
• Entering Field Descriptions in Design View
• Setting constraints on Tables
• Saving a Table in Design View
Short Text Contains up to 255 characters of text, or a combination of text, numbers, and other info.
A longer type of text field. It can store up to about 1 GB of text, but controls used to display its
Long Text
values can only show the first 64,000 characters.
Can contain only numeric data on which to perform calculations, NOT phone numbers or zip
Number codes. As you do not perform calculations with these numbers, they are text fields. Can be
either 1, 2, 4, 8, or 16 bytes in size, depending on the related “Field Size” setting.
An 8-byte numeric value which is compatible with the SQL_BIGINT data type in ODBC and
Large Number
which is used for efficiently calculating large numbers that aren’t currency.
Date/Time Contains an 8-byte date or time code. Useful for Date/Time calculations.
Date/Time A 42-byte date or time code similar to the Date/Time data type, but with a larger date range,
Extended higher fractional precision, and compatibility with the “datetime2” data type in SQL Server.
An 8-byte number data type in function, but formatted as currency, with 4 decimal places of
Currency precision. Uses fixed point calculation, which is faster than the Number data type’s floating
point calculation.
Create Tables in Microsoft Access
Assigns a unique 4-byte numeric ID to all records entered in the table. Useful as a primary key
AutoNumber
field. If used for Replication ID, then it instead contains 16 bytes.
Stores Boolean (logical) data, like “Yes/No,” “True/False,” “On/Off,” “-1/0.” Used when only two
Yes/No
possible values in a field can exist.
Connects to objects in Windows-based applications. You can use OLE Object data types for
OLE Object
ActiveX objects, pictures, calendars, and other types of files.
Allows you to attach any type of supported file, such as images, or spreadsheets, for example.
Attachment Provides greater attachment flexibility than the OLE Object field and also uses storage space
more efficiently than OLE fields.
Allows you to create a calculated field, which contains a value that is derived by performing a
Calculated
function on other table fields using an expression that you create.
Not an actual data type. Selecting this instead helps you set up a lookup field, which contains
Lookup Wizard… values from another table, query, or values you enter by hand, which then validate this field’s
values. Useful for combo boxes and list boxes in forms.
Create Tables in Microsoft Access
Constraints enable you to further control how data is entered into a table and are
used to restrict values that can be inserted into a field and to establish referential
integrity.
Constraint Description
NULL/NOT NULL Used to indicate if a field can be left blank when records are entered into a table.
FOREIGN KEY Used to link records of a table to the records of another table.
Note:
• To create a one-to-one relationship Both of the common fields (typically the primary
key and foreign key fields) must have a unique index. This means that the Indexed
property for these fields should be set to Yes (No Duplicates). If both fields have a
unique index, Access creates a one-to-one relationship.
• To create a one-to-many relationship The field on the one side (typically the primary
key) of the relationship must have a unique index. This means that the Indexed
property for this field should be set to Yes (No Duplicates). The field on the many side
should not have a unique index. It can have an index, but it must allow duplicates. This
means that the Indexed property for this field should be set to either No or Yes
(Duplicates OK). When one field has a unique index, and the other does not, Access
creates a one-to-many relationship.
Create Tables in Microsoft Access