0% found this document useful (0 votes)
4 views

Database Fundamentals Lab3

Database lab
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Database Fundamentals Lab3

Database lab
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 70

Lab

3
Database
Fundament
als
Introduced by
Rawan Ayman & Nada Marei
Databa Fundament
se
Table of Content als
1 Understanding the user requirements

2 The Conceptual design and Creating the ER diagram

3 ER diagram To Relational Mapping

4 The Normalization step

5 Building the database using the selected


DBMS
If you want to create a database, The design process consists of the following
steps:
1. Define the Purpose of the Database
Understand the user requirements to define
the purpose of the database

2. Identify Entities and Relationships


Prepare the conceptual design, enhance the
design, mapping it to relational, define the
constrains.
3. Normalise the Data
Normalization is an important step in the database design
process as it helps to reduce data redundancy and ensure
data consistency.

4. Choose a Database Management System


the scalability of the system, its compatibility with the
organization's existing infrastructure, its security features,
and its performance capabilities.

5. Test the Database Design


It ensures that the database meets the organization's
requirements and performs optimally.
Conceptual design - Entity relationship
(ER) data model
Entity relationship (ER) to Enhanced Entity Relationship
(EER) Model
Enhanced ER (EER) model:
 Created to design more accurate database schemas.
 Reflect the data properties and constraints more precisely.
 More complex requirements than traditional applications.

EER model includes all modelling concepts of the ER model


In addition, EER includes:
 Subclasses and super classes
 Specialization and generalization
 Category or union type
 Attribute and relationship inheritance
Entity relationship (ER) to Enhanced Entity Relationship
◾ (EER) Model
1.The database keeps track of three types of persons:
employees, alumni, and students. A person can
belong to one, two, or all three of these types. Each person
has a name, SSN, sex, address, and birth date.
◾ 2. Every employee has a salary, and there are three types
of employees: faculty, staff, and student assistants.
Each employee belongs to exactly one of these types. For each
alumnus, a record of the degree or degrees that he or
she earned at the university is kept, including the name of
the degree, the year granted, and the major
department. Each student has a major department.
◾ 3. Each faculty has a rank, whereas each staff member
has a staff position. Student assistants are classified
further as either research assistants or teaching
assistants, and the percent of time that they work is
recorded in the database. Research assistants have their
research project stored, whereas teaching
assistants have the current course they work on.
◾ 4. Students are further classified as either graduate or
undergraduate, with the specific attributes degree
program (M.S., Ph.D., M.B.A., and so on) for graduate
students and class (freshman, sophomore, and so on)
Conceptual design - Entity relationship
(ER) data model
Entity relationship (ER) To Relational
Mapping
ER Conceptual Relational Mapping
Schema
Entity relationship (ER) To Relational
Mapping
ER Conceptual Relational Mapping
Schema
Entity relationship (ER) To Relational
Mapping
Normalization

Read Lecture
4
Entity relationship (ER) to Enhanced Entity Relationship
◾ (EER) Model
1.The database keeps track of three types of persons:
employees, alumni, and students. A person can
belong to one, two, or all three of these types. Each person
has a name, SSN, sex, address, and birth date.
◾ 2. Every employee has a salary, and there are three types
of employees: faculty, staff, and student assistants.
Each employee belongs to exactly one of these types. For each
alumnus, a record of the degree or degrees that he or
she earned at the university is kept, including the name of
the degree, the year granted, and the major
department. Each student has a major department.
◾ 3. Each faculty has a rank, whereas each staff member
has a staff position. Student assistants are classified
further as either research assistants or teaching
assistants, and the percent of time that they work is
recorded in the database. Research assistants have their
research project stored, whereas teaching
assistants have the current course they work on.
◾ 4. Students are further classified as either graduate or
undergraduate, with the specific attributes degree
program (M.S., Ph.D., M.B.A., and so on) for graduate
students and class (freshman, sophomore, and so on)
Relational Mapping
Structured Query Language (SQL)
What is SQL?
SQL stands for Structured Query Language
SQL lets you access and manipulate databases

SQL divided in to:


DDL: Data definition Language
1.CREATE DATABASE
2.DROP DATABASE
3.Create Table
4.ALTER TABLE
5.DROP TABLE
DML: Data manipulation Language
1.INSERT
2.SELECT
3.UPDATE
4.DELETE
https://www.janbasktraining.com/blog/top-sql-commands/
DDL: Data definition
Language
1. CREATE DATABASE
Used to create a new database
Example :
Create a data base named my_db
>> Create Database mydb;

2. DROP DATABASE
Used to delete a database
Example :
Drop a data base named my_db
>>Drop database my_db;
DDL: Data definition
Language
3. CREATE TABLE
Used to create tables in a database
Syntax: – CREATE TABLE table _name( column_name1 data_type(size), column_name2
data type(size), column_name3 data type(size), .... );

Example :
Create the above table with name persons.
Create table Persons(PersonID int, LastName varchar(255), FrirstName
varchar(255),Address varchar(255), city varchar (255) );
DDL: Data definition
Language
Columns types is:
1) Text
- Char(length)
- Varchar(length)
- Text
- longtext

2) Numbers
- Integers (tinyint, mediumint, integer, bigint)
- Floating point (float, double, decimal)

3)Date
- Date
DDL: Data definition
4. ALTER TABLE Language
Used to add, modify or delete column in a table

4.1 ADD Column to a table


Syntax: ALTER TABLE table_name ADD column_name datatype;
Example: ADD “DateOfBirth” column to persons.
>> Alter table persons ADD DateOfBirth int;

4.2 MODIFY COLUMN in a table


Syntax: ALTER TABLE table_name MODIFY column_name datatype;
Example : Alter the data type of “DateOfBirth” column to Date.
>>Alter Table Persons Modify DateOfBirth Date;

4.3 Delete column from a table


Syntax: ALTER TABLE table_name DROP COLUMN column_name;
Example :
Drop column “DateOfBirth” from persons table
>> Alter Table Persons drop column DateOfBirth ;
DDL: Data definition
Language
5.DROP TABLE
Used to deletes a table from a database

Syntax:
DROP TABLE table_name; Example : DROP the “persons” table .
>> Drop Table Persons;
Thank Any questions?

You

You might also like