Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI-100 Introduction to Computing

Similar presentations


Presentation on theme: "CSCI-100 Introduction to Computing"— Presentation transcript:

1 CSCI-100 Introduction to Computing
Databases Part II

2 Database Models Define the way a database organizes data
Four main models Hierarchical Network Relational Object-oriented

3 Relational Database Each entity is stored in a separate table
Columns represent fields Rows represent records Tables are linked by a relationship between primary and foreign keys

4 Integrity Constraints
Define acceptable values for a field For example, the value of a month cannot be greater than 12 Primary keys cannot be duplicated Foreign keys cannot be used unless they exist as a primary key A SalesID that is used in the customer table must exist as a primary key in the salesperson table

5 Primary Key Foreign Key A field that uniquely identifies a record
SalesID can be a primary key for the SalesPerson table Once a SalesID appears in the table, no other salesperson can have that ID Foreign Key A field in one table that is a primary key in another table SalesID can be used in the Customer table to identify the salesperson who serves that customer The same SalesID can appear in many customer records (a salesperson can serve many customers)

6 Entity-Relationship (ER) Diagram
The logical structure of a database can be expressed graphically by an ER diagram. Such a diagram consists of some major components Rectangles, which represent entities Ellipses, which represent attributes Diamonds, which represent relationships Lines, which link attributes to entities and entities to relationships EXAMPLE: ER diagram for a bank (DONE IN CLASS)

7 A database that conforms to an ER diagram can be
represented by a collection of tables Converting an ER diagram to a table format is the basis for deriving a relational database from and ER diagram design EXAMPLE: Relational database from bank ER diagram (DONE IN CLASS)


Download ppt "CSCI-100 Introduction to Computing"

Similar presentations


Ads by Google