sql - Basic question: how to properly redesign this schema -
i hopping on project sits on top of sql server 2008 db seems inefficient schema me. however, i'm not expert @ sql, seeking guidance.
in general, schema has tables this:
id | | b
- id unique identifier
- a contains text, such animal names. there's little variety; maybe 3-4 different values in thousands of rows. vary time, still small set.
- b 1 of 2 options, stored text. set finite.
my questions follows:
- should create table names contained in a, id , value, , set id primary key? or should put index on column in table? right now, list of a's, "select distinct(a) table" seems inefficient me.
- the table has multitude of columns properties of a. like: color, age, weight, etc. think better suited in separate table with: id, animalid, property, value. each property unique animal, i'm not sure how schema enforce (the current schema implies it's column, can have 1 value each property).
right db readable human, size growing fast , feel design inefficient. there not index @ anywhere. said i'm not pro, read more on subject. goal have fast system. advice!
this sounds database might represent veterinary clinic.
if table describe represents various patients (animals) come clinic, having properties specific them best on primary table. but, column "a" contains species name, might worthwhile link secondary table save on redundancy of storing names:
for example:
patients -------- id name speciesid color dob weight 1 spot 1 black/white 2008-01-01 20 species ------- id species 1 cocker spaniel
if main table should instead grouped customer or owner, may want add animals table , link it:
customers --------- id name 1 john q. sample animals ------- id customerid speciesid name color dob weight 1 1 1 spot black/white 2008-01-01 20 ...
as original column b, consider converting boolean (bit
) if need store 2 states. barring that, consider char
store fixed number of characters.
Comments
Post a Comment