Please upgrade your web browser

These pages are built with modern web browsers in mind, and are not optimized for Internet Explorer 8 or below. Please try using another web browser, such as Internet Explorer 9, Internet Explorer 10, Internet Explorer 11, Google Chrome, Mozilla Firefox, or Apple Safari.

Thoughts on these SQL Server tables?

Veteran

David Roman Raleigh, NC

I'm aiming to create an app to track one's exercises, reps, sets, and weight used. Right now, I'm building out my tables, but would like feedback (I'm particularly concerned about the Session table).

--the table(s) have pre-made information on the app directly (aka lookup tables)

Create Table AppExercises (
AppExerciseID int Primary Key,
AppExerciseName varchar(50) Not Null,
Description varchar(MAX) Not Null,
CreatedOn datetime Not Null Default (getdate()),
LastModified datetime Default (getdate())
);

--tables below require user input

Create Table CustomExercises (
CustomExerciseID int Primary Key,
CustomExerciseName varchar(50) Not Null,
Description varchar(MAX),
CreatedBy int Foreign Key References Users (UserID),
CreatedOn datetime Not Null Default (getdate()),
LastModified datetime Default (getdate())
);

Create Table Users (
UserID int Primary Key,
FirstName varchar(50) Not Null,
LastName varchar(50) Not Null,
BirthDate date,
Sex varchar(50),
Email varchar(50) Not Null,
CreatedOn datetime Not Null Default (getdate()),
LastModified datetime Default (getdate()),
);

----------------------------------------------------------------------

--the Session table

Create Table Session (
SessionID int Not Null,
Date datetime Not Null,
DoneBy int Foreign Key References Users (UserID),
AppExercise int Foreign Key References AppExercises (AppExerciseID),
CustomExercise int Foreign Key References CustomExercises (CustomExerciseID),
Sets int Not Null,
Reps int Not Null,
Weight int Not Null,
CreatedOn datetime Not Null Default (getdate()),
LastModified datetime Default (getdate()),
primary key (SessionID, Date)
);

5 May 2021 2 replies Education & Training

Answers

Advisor

Rick Spiewak Annapolis, MD

Just a small suggestion - you don't need to repeat the table name as part of the column name, it will be distinguished by the table anyway. So AppExerciseID works fine as ExerciseID. Also some languages would prefer ExerciseId as a name when referencing it.

Also, be careful about the PII (Personally Identifiable Information) in your Users table. If you don't need it, don't keep it. A breach could prove costly to you. If you feel you need this data, you should encrypt the database. Be aware that recovering encrypted data if you misplace the keys can be difficult!

Advisor

Andrea Bryant New York, NY

Hi David,

Thank you for your service, and for posting your question! Unfortunately, absent much app development experience myself, I'm not able to give you much in the way of feedback. However, I have reached out to some advisors who may have more relevant insight, and will post their answers when I hear back from them!

When you do develop such an app - please let me know. I would be delighted to be a BETA tester!

Best,

Andrea

Your Answer

Please log in to answer this question.

Sign Up

You can join as either a Veteran or an Advisor.

An Advisor already has a career, with or without military experience, and is willing to engage with and help veterans.
Sign Up as an Advisor.

A Veteran has military experience and is seeking a new career, or assistance with life after service.
Sign Up as a Veteran.