relational-database

Normalization of an 1:1 or 1:0 relationship

家住魔仙堡 提交于 2019-12-01 00:49:42
when using relation databases and you want 3NF (do you call it 3NF in english?), then you pull 1:1 relationsships together into one table. But what happens if the rationship is 1:0/1 (/ meaning or)? Then you keep them separated to avoid blank spaces in tables? Kepping them apart is valid 3NF in ths case? Third normal form basically means that an attribute (or column) depends on the key, the whole key and nothing but the key (so help me, Codd). If you have an attribute which is either there or not there, that attribute itself may still follow the rules. In those cases, I would simply keep the

Django teacher students easy solution. Use separate tables, or permissions and groups? How? Other ideas?

巧了我就是萌 提交于 2019-12-01 00:41:48
How would you cope with following problem? There are teachers, and students. Student can not view pages dedicated to teachers, and teachers can view pages dedicated to students. Teachers can have list of just students they teach. I want both teachers and students to use build in User to let them login. I have following ideas: Separate table for teacher and student with foreign key to build in user? - but the question is, can I easily render pages and distinguish who is teacher and who is student. Permissions? Groups? and just one table Users? But to be honest I did not find the way how could I

MySQL Database design. Inserting rows in 1to1 tables.

♀尐吖头ヾ 提交于 2019-11-30 23:27:14
What is the best way to insert rows into tables with references 1 to 1 of each other? I mean, in a MySQL 5.5 and tables InnoDB, I have a database design similar to the following The problem arises when we try to insert rows in table1 and table2. Since there is no multi-table insert in MySQL, I can not insert a row becouse the foreign keys are NOT NULL fields in both tables and should be inserted simultaneously in both. Which is the bes way to solve this problem? I have in mind 3 possible solutions, but I want to know if there are more than these or which is the best and why. Set the foreign

Import Excel Data to Relational Tables at MySQL

眉间皱痕 提交于 2019-11-30 23:15:38
I have three tables at my MySQL database. First one is cities, second one is towns and third one is districts. Every town has many districts. My table details: cities: cityid, city name towns: townid, cityid, townname, continent districts: districtid, townid, districtname I have an excel file that holds the town and district names of one city. It has three columns. city name, town name, district name city name is always same at this excel sheet. town name has duplicates because of its districts. I mean for every district of a town: city name and town names are same and district names are

Storing inherited objects in a database

孤街醉人 提交于 2019-11-30 22:51:52
I'm trying to figure out the best way to map inheritance relationships in an object model into a relational database. For example consider the following class structure. public Class Item { public String Name{get; set;} public int Size {get; set} } public Class Widget:Item { public String Color{get; set;} } public Class Doohicky:Item { public String Smell{get; set;} } Here's are a few options I'm considering for how to save this structure to a database. Options 1: Single Table for all item types Items Table: ItemID, Name, Color, Smell This sucks as it would require NULL values. Options 2:

Which normal form does this table violate?

风格不统一 提交于 2019-11-30 22:40:22
Consider this table: +-------+-------+-------+-------+ | name |hobby1 |hobby2 |hobby3 | +-------+-------+-------+-------+ | kris | ball | swim | dance | | james | eat | sing | sleep | | amy | swim | eat | watch | +-------+-------+-------+-------+ There is no priority on the types of hobbies, thus all the hobbies belong to the same domain. That is, the hobbies in the table can be moved on any hobby# column. It doesn't matter on which column, a particular hobby can be in any column. Which database normalization rule does this table violate? Edit Q. Is "the list of hobbies [...] in an arbitrary

Best method to verify multi-level relational dependencies

牧云@^-^@ 提交于 2019-11-30 22:21:35
Suppose you have entities A, B, C and D. D relates to C C relates to B B relates to A Furthermore, user is only allowed to operate on D , if user owns A . At a certain state in an application, you include a link to a page, which accesses D. Thus, you includes D's ID as a GET or POST parameter. If user clicks on the link, the application retrieves D's ID and begins to operate on D. Simple apps use URLs like this [modulo URL-rewriting]: http://www.myServer.com/?action=1234&entity=D&ID=23 How to verify if user is allowed to operate on D? A) The obvious solution would be this: Given D, find C,

SQL two tables and creating a link table

梦想与她 提交于 2019-11-30 21:50:18
I have two tables: Employee (ID, Name, Address) and Store(ID,Address) and I would like to record information about people who work in each store. I thought of making a new table called Employee_List table. My questions: 1- Employee_List and Employee has one-to-many relation, right? 2- Employee_list to store has one-to-one relation, right? 3- How to define foreign and primary keys for Employee_List table? Employee_list should have: employee_listid (INT PK) employee_id (INT FK) store_id (INT FK) I would recommend changing the table name to represent the composite table, i.e. EmployeeStores .

6NF and historical attribute data

北慕城南 提交于 2019-11-30 20:45:05
When using a database normalized accoring to 6NF principles, how would you store historical attribute data? Let say for example we take this example from @PerformanceDBA but with the following extra requirement: We need to store historical data for all our products, we should be able to just enter a date and get a snapshot of the attributes of the product at that particular time. A more practical example : Suppose the disks and CPU's from the example above are virtual and a user can change the disk capacity at will. How can we alter the database so that we can retrieve the attributes of a

What is the best way to store a series of images in MySQL?

别等时光非礼了梦想. 提交于 2019-11-30 19:38:17
问题 I've been working on a SQL model for my website, and I'm really conflicted on how to store these images in my database for use around the site. First, each profile will contain a relevant 10 images total. 4 screenshots, with thumbnails, and two extra images. These images will be used all around the site. Is storing the image path for each image in it's own column fine? A buddy tells me that I should place all images in it's own table and cross-reference them for better performance. I'll be