








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









1 | P a g e
By the end of this lab, students will be able to: Explain the basic concept of the relational model. Understand a relation/table. Identify rows and columns in a relation. Understand the concept of a domain. Understand the meaning of a schema. Differentiate between a table, row, column, and domain. Create a simple relational table using MySQL Workbench. Inspect a table structure using MySQL. Relate theoretical concepts of the relational model to an actual database table.
Hardware PC/Laptop Keyboard and Mouse Internet connection Software MySQL Server MySQL Workbench Windows/Linux/macOS Other Requirements LMS access Lab 01 database environment Folder for screenshots and SQL files
The relational model is a database model in which data is organized into relations. In practical database systems, a relation is commonly represented as a table. For example: STUDENT: Student_ID Name Program Semester 101 Ali BSCS 3 102 Sara BSAI 2 103 Ahmed BECSE 4
2 | P a g e This table represents student-related data.
In the relational model, a relation represents a collection of related data. In a practical database, we usually see a relation as a table. For example: Student can be represented as: Student_ID Name Program 101 Ali BSCS 102 Sara BSAI Here, Student is the relation/table.
A row represents one record in a table. Example: Student_ID Name Program 101 Ali BSCS The complete record:is one row.
A column represents a particular attribute or type of information. In the following table: Student_ID Name Program 101 Ali BSCS 102 Sara BSAI
A domain defines the set of valid values that can be stored in a particular attribute/column. For example: Age : A domain might contain: 18, 19, 20, 21, 22... Semester: A suitable domain might contain: 1, 2, 3, 4, 5, 6, 7, 8 Student_Name The domain consists of valid text values representing student names. In MySQL, data types help define what kind of values a column can store. For example: Student_ID INT and: Student_Name VARCHAR(50)
4 | P a g e
Consider this table: STUDENT Student_ID Name Program Semester 101 Ali BSCS 3 102 Sara BSAI 2 103 Ahmed BECSE 4 You must identify:
Open the database created in Lab 01. For example: USE UniversityDB; Create a table: CREATE TABLE Students ( Student_ID INT, Student_Name VARCHAR(50),
5 | P a g e Program VARCHAR(50), Semester INT ); Execute the command.
Objective To identify the columns and their data types in a relational table. Execute: DESCRIBE Students; Observe the output.
7 | P a g e Ans: I used VARCHAR as a Data-type for Student_Name.
Create a table named: Courses with suitable columns such as: CREATE TABLE Courses ( Course_ID INT, Course_Name VARCHAR(50), Credit_Hours INT, Department VARCHAR(50) ); Execute the command. Then execute: SHOW TABLES;
8 | P a g e Observe You should now see the tables inside your selected database. Task Identify: Database/schema Tables
10 | P a g e Relational Concept Your Database Example semesters can be added. FOR COURSES: FOR COURSES_NAME: Suggested by University. FOR CREDIT_HOURS: Credit hours can maybe 21, but not more than that for Bachelor’s degree. The max limit is 21 Hours. FOR DEPT: Again, Selected and offered by University Management. Discussion: You should explain how the table created in MySQL represents the relational model. Ans: First of all, I’d a database naming UNIVERSITYDB , it was shown in Schema. Then I created Tables having Columns and Rows. In Columns I specified data I required called as attributes , the table is empty table having no record in rows but, it is a table having row and columns. At the end, We have some limitations for every attribute for the accuracy of data, and that’s its Domain. I worked upon this model: Database ↓ Schema ↓ Table / Relation ↓ Columns ↓ Rows And: Column → Attribute / type of information Row → Record Domain → Valid set/type of values
11 | P a g e
LAB TASK 1 : Create Table Create a table named: Books The table must contain at least 4 appropriate columns. You must choose suitable: Column names Data types LAB TASK 2 : Identify the Components For your Books table, identify: Relation/Table: BOOKS Columns: 4 COLUMNS (BOOK_NAME , BOOK_AUTHOR_NAME , BOOK_PUBLISHING_YEAR , AND BOOK_PRICE) Rows: NULL Domain of each column: 1)- BOOK_NAME BOOK ONLY WRITTEN BY THE AUTHOR GIVEN. EXAMPLE: “THE POWER OF NOW”. 2)- BOOK_AUTHOR_NAME ONLY THE AUTHOR OF THE BOOK. EXAMPLE: “ EKHART TOLLE”. 3)- BOOK_PUBLISHING_YEAR ONLY THE REAL YEARS OF PUBLISHING BOOK. EXAMPLE: THE BOOK “ THE POWER OF NOW ” WAS FIRST PUBLISHED IN “ 1997 ”. 4)- BOOK_PRICE THE ONLY REAL PRICE. EXAMPLE: RS.250/- TO RS.350/-. Schema/Database: COLLEGEDB
13 | P a g e . LAB TASK 5 : View Table Structures Use: DESCRIBE Books; and: DESCRIBE Authors;
14 | P a g e
Can a table contain only columns and no rows? Ans: Yes , In that case the table is called EMPTY TABLE. Can a table contain multiple rows? Ans: Obviously , a table can contain multiple rows according to the rcords to put. Can two columns of a table have different data types? Ans: Yes , two different columns can have two different data-types. Why should a column have an appropriate domain? Ans: To take/get exact and accurate data , appropriate domain is used. If a Semester column is defined as INT, should we store "Third Semester" in it? Why? Ans: No , we can’t. Cuz, we defined its data-type as INT , which means numbers/digits only. While, Third Semester requires data-type VARCHAR cuz it contains letters.