Scenario to RDBMS in SQL Server

tltanhueco1990

New member
Local time
Tomorrow, 02:43
Joined
Mar 15, 2023
Messages
29
Good day, everyone!

I have this new project where I need to turn these scenarios into a DB with ERDs by CREATE DATABASE/CREATE TABLE without typing any actual queries, but all tables are in a one-to-many relationship:
DB_Creation.png

DB_Creation2.png

DB_Creation3.png


I need to set associated primary keys and foreign keys to each other. Here's what I've done so far (I decoded in a notepad first before I create a DB in SQL Server):

4.1:EMPLOYEE PARKING SPACE
PARKINGLOT(LotCode,SpaceNumber,Description)
EMPLOYEE(Name,Address,DateHired,OfficeNumber,CellNumber,Email)
VEHICLE(PlateNumber,VehicleState,Make,Model,Year,Color)

4.2:RESTAURANT REVIEW
USER(ScreenName,ActualName,Address,Email,PhoneNumber)
RESTAURANT(Name,Address,PhoneNumber,URL,Category)
REVIEW(Scale,DinnerCost,Comments)

5.4:ALUMNI OFFICE
ALUMNI[Name*,Address(StreetAddress,City,State,ZipCode),HomeNumber,CellNumber,Email]
DEGREE(StudentName,YearGraduated,Degree,Major,SchoolAttended)
UNIVERSITY(SchoolShortName-varchar(40),SchoolFullName-varchar(100))
GIFT(DonationDate,Donator,DonatedAmount)
- DEGREE(StudentName) FK to ALUMNI(Name)

5.5:MOTOR DEALERSHIP
SALESPERSON(Name*,EID*,DateHired,SellingDate*,SoldTo)
CUSTOMER[Name*,CID*,Address(City,State,ZipCode),PhoneNumber,Email,PurchasedModel,SalespersonName]
MODEL(Name*,EngineSize,DateIntroduced)
MODELSALE(ModelName,SerialNumber,DateSold,PriceSold,Purchaser,CID,Seller,EID)
- MODELSALE(Purchaser) FK to CUSTOMER(Name)
- MODELSALE(CID) FK to CUSTOMER(CID)
- MODELSALE(Seller) FK to SALESPERSON(Name)
- MODELSALE(EID) FK to SALESPERSON(EID)
- MODELSALE(ModelName) FK to MODEL(Name)
- MODELSALE(DateSold) FK to SALESPERSON(SellingDate)

FK (Foreign Key)
* PK (Primary Key)
---
Am I missing something? Did I do something wrong with the relations? There's the part where I need to set a relationship to, for example, the purchased model to the customer and salesperson's names, but the data shows there's a first name, middle name and last name which confuses me.
 
Last edited:
it's a though school assigment alright.
 
You need to work out the relationships and create a joining table if the relationship is many to many

you will also need to add primary keys to each table and foreign keys as required
 

Users who are viewing this thread

Back
Top Bottom