Professional Documents
Culture Documents
Data Organization Organizes data into tables Data Organization Organizes data into tables
with rows and columns. with relationships between
Data Retrieval Basic querying; may involve Data Retrieval Advanced querying with
scanning entire files. SQL; optimized for efficient
retrieval.
Data Some separation between
Independence physical and logical data. Data Offers significant data
Independence independence, both logical
Data Integrity Relatively better but still and physical.
susceptible to redundancy.
Data Integrity Enforces data integrity
Scalability Faces challenges with larger through constraints.
datasets.
Scalability Scalable to handle growing
Security Limited security features. data volumes and user
loads.
Complexity More complex than manual
systems but lacks relational Security Offers robust security
capabilities. features (user
authentication, encryption).
added to table
To confirm if you have connected:
Server_name [(none)]>
Syntax for CREATING databases: Syntax for FOREIGN KEY:
Server_name [(none)]> CREATE DATABASE Format:
database_name; Server_name [(Student)]> CREATE TABLE table_name2
>(
Example: > column_name data_type(size) constraints,
Server_name [(none)]> CREATE DATABASE Student; > FOREIGN KEY(column_name) REFERENCES
table_name2(column_name)
To confirm if the database has been created: > );
Server_name [(none)]> SHOW DATABASES;
*Displays list of databases* Server_name [(Student)]> CREATE TABLE table_name2
>(
> StudentNum varchar(5),
Syntax for SELECTING a database: > Lastname varchar(50) NOT NULL,
> FirstName varchar(50) NOT NULL,
Server_name [(none)]> USE Student; > Address varchar(50),
Server_name [(Student)]> > City varchar(20),
> Birthday date,
> StudentID varchar(5),
Syntax for DELETING a database: > FOREIGN KEY(StudentID) REFERENCES
table_name2(StudentID)
Note: When deleting a database, have a backup of it.
>);
Server_name [(Student)]> DROP DATABASE;
Syntax for RESTORING records in a table: DATA MODEL BASIC BUILDING BLOCKS
MANY-TO-MANY RELATIONSHIP
⤷ Let's consider a scenario with two entities:
Student and Course.
2. Create a table for the "many" side of the ⤷ Business Rule: Each student can enroll in
relationship. In this example, it's the Employee multiple courses, and each course can have
table. Include a foreign key that references the multiple students.
primary key of the "one" table: ⤷ Database designers label the relationship
“STUDENT learns COURSE” as M:N
Relational Model:
Entity-Relationship Diagram:
Query:
SELECT * FROM Employee WHERE DepartmentID = 1;
Example 2: