Database Fundamentals Lab3
Database Fundamentals Lab3
3
Database
Fundament
als
Introduced by
Rawan Ayman & Nada Marei
Databa Fundament
se
Table of Content als
1 Understanding the user requirements
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
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
Syntax:
DROP TABLE table_name; Example : DROP the “persons” table .
>> Drop Table Persons;
Thank Any questions?
You