You are on page 1of 5

Database Fundamental (TIS 1101)

Tutorial 2

Q1. What is entity integrity? Give an example.

Entity integrity is the condition in which each row in the table has its own unique
identity.

For example, each student has a student ID. Thus, in a table, the student ID is a
unique identity for each row.

Q2. A relational table is a two-dimensional table that composed of rows and columns.
What are the key characteristics of a relational table?

- Each table row (tuple) represents a single entity occurrence within the entity
set
- Each table column represents an attribute, and each column has a distinct
name
- Each row/column intersection represents a single data value
- All values in a column must conform to the same data format
- Each column has a specific range of values known as the attribute domain
(e.g., gender – Female/Male)
- The order of the rows and columns is immaterial to the DBMS
- Each table must have an attribute or a combination of attributes that uniquely
identifies each row

Q3. A data model is a simple representation of complex real-world data structures.


What are the basic building blocks of a data model?

1. Entity – is a person, place, thing or event about which data are collected
2. Attribute – a characteristic of an entity
3. Relationship – describes the association among entities
4. Constraint – a restriction placed on data (e.g., Grade must be between A, B, C,
D or F)
Q4. What is a foreign key?

Foreign key is the primary key of one table that has been placed into another table
to create a common attribute.

Q5. Briefly explain the THREE different relationships within the relational database

- 1:M relationship (one entity is related to many entity)

- 1:1 relationship (one entity is related to only one entity)

- M:N relationship (associations among two or more entities in which one


occurrence of an entity is associated with many occurrences of a related
entity)

Q6. Define business rules. Why business rules are important? Give an example.

Business rule is a brief, precise, unambiguous description of a policy, procedure


or principle within an organization.

Business rules are important since they are used to define entities, attributes,
relationships and constraints, which form the basis for data modeling.

The following are some examples:

- A student can enroll up to a maximum of 4 subjects per semester.


- A college has many departments, but each department belongs to a single
college. (This business rule reflects a university that has multiple colleges
such as Business, Liberal Arts, Education, Engineering, etc.)
- A client may sign many contracts, but only one client signs each contract.
- A sales representative may write many contracts, but one sales representative
writes each contract.
- Student’s GPA must be between 0 and 4.0
Q7. Based on the following two tables, what will be the results of these
relational algebra operations?

Table1
Code CourseName Credit
SAK3100 Programming 4
SAK3304 Computer 4
MTK3200 Algebra 4
MGT2102 Business 2

Table2
Code CourseName Credit
MTK3200 Algebra 4
MGT2102 Business 2
ECO4300 Economic 2

(a) Select CourseName where credit is equal to 4 from Table1

CourseName
Programming
Computer
Algebra

(b) Table1 union Table2

Code CourseName Credit


SAK3100 Programming 4
SAK3304 Computer 4
MTK3200 Algebra 4
MGT2102 Business 2
ECO4300 Economic 2
(c) Table1 different Table2

Code CourseName Credit


SAK3100 Programming 4
SAK3304 Computer 4

(d) Table1 intersect Table2

Code CourseName Credit


MTK3200 Algebra 4
MGT2102 Business 2

Q8. Given the following tables:

A B1
StudID LecID LecID
S1 L1 L2
S1 L2 2B
S1 L3 L2
S1 L4 L4
S2 L1 3B
S2 L2 L1
S3 L2 L2
S4 L2 L4
S4 L4

What are the results of the following operations:

(a) A divide B1

StudID
S1
S2
S3
S4
(b) A divide B2

StudID
S1
S4

(c) A divide B3

StudID
S1

** Note to tutor: If time permits, can expose student to create simple table such as.

Create databse dbStudent

Connect to dbStudent

create table STUDENT


(
student_id int,
name varchar(30),
age int,
gender char(1)
);

You might also like